Commit cebac4fa authored by Adrian Negreanu's avatar Adrian Negreanu Committed by Adrian Negreanu

sqlite3: shuffle the code so it's aligned with xmlgen.cpp

this way, it's easier to see what's missing from sqlite3gen
Signed-off-by: 's avatarAdrian Negreanu <groleo@gmail.com>
parent 1adc7fd0
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
//#define DBG_CTX(x) printf x //#define DBG_CTX(x) printf x
#define DBG_CTX(x) do { } while(0) #define DBG_CTX(x) do { } while(0)
static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def);
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
const char *i_q_includes="INSERT OR REPLACE INTO includes " const char *i_q_includes="INSERT OR REPLACE INTO includes "
"( local, id_src, dst ) " "( local, id_src, dst ) "
...@@ -238,8 +240,6 @@ class TextGeneratorSqlite3Impl : public TextGeneratorIntf ...@@ -238,8 +240,6 @@ class TextGeneratorSqlite3Impl : public TextGeneratorIntf
// the list is filled by linkifyText and consumed by the caller // the list is filled by linkifyText and consumed by the caller
}; };
static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def);
static void bindTextParameter(sqlite3_stmt *stmt,const char *name,const char *value, bool _static=TRUE) static void bindTextParameter(sqlite3_stmt *stmt,const char *name,const char *value, bool _static=TRUE)
{ {
...@@ -326,88 +326,6 @@ static void stripQualifiers(QCString &typeStr) ...@@ -326,88 +326,6 @@ static void stripQualifiers(QCString &typeStr)
} }
} }
////////////////////////////////////////////
static void writeInnerClasses(sqlite3*db,const ClassSDict *cl)
{
if (!cl) return;
ClassSDict::Iterator cli(*cl);
ClassDef *cd;
for (cli.toFirst();(cd=cli.current());++cli)
{
if (!cd->isHidden() && cd->name().find('@')==-1) // skip anonymous scopes
{
bindTextParameter(i_s_innerclass,":refid",cd->getOutputFileBase());
bindIntParameter(i_s_innerclass,":prot",cd->protection());
bindTextParameter(i_s_innerclass,":name",cd->name());
if (-1==step(db,i_s_innerclass))
return;
}
}
}
static void writeInnerNamespaces(sqlite3 * /*db*/,const NamespaceSDict *nl)
{
#warning WorkInProgress
if (nl)
{
NamespaceSDict::Iterator nli(*nl);
NamespaceDef *nd;
for (nli.toFirst();(nd=nli.current());++nli)
{
if (!nd->isHidden() && nd->name().find('@')==-1) // skip anonymouse scopes
{
// t << " <innernamespace refid=\"" << nd->getOutputFileBase()
// << "\">" << convertToXML(nd->name()) << "</innernamespace>" << endl;
}
}
}
}
static void writeTemplateArgumentList(sqlite3* /*db*/,
ArgumentList * /*al*/,
Definition * /*scope*/,
FileDef * /*fileScope*/,
int /*indent*/)
{
#warning WorkInProgress
}
static void writeTemplateList(sqlite3*db,ClassDef *cd)
{
writeTemplateArgumentList(db,cd->templateArguments(),cd,0,4);
}
static void generateSqlite3Section(sqlite3*db,
Definition *d,
MemberList *ml,const char * /*kind*/,const char * /*header*/=0,
const char * /*documentation*/=0)
{
if (ml==0) return;
MemberListIterator mli(*ml);
MemberDef *md;
int count=0;
for (mli.toFirst();(md=mli.current());++mli)
{
// namespace members are also inserted in the file scope, but
// to prevent this duplication in the XML output, we filter those here.
if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==0)
{
count++;
}
}
if (count==0) return; // empty list
for (mli.toFirst();(md=mli.current());++mli)
{
// namespace members are also inserted in the file scope, but
// to prevent this duplication in the XML output, we filter those here.
//if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==0)
{
generateSqlite3ForMember(db,md,d);
}
}
}
static int prepareStatement(sqlite3 *db, const char* query, sqlite3_stmt **statement) static int prepareStatement(sqlite3 *db, const char* query, sqlite3_stmt **statement)
{ {
int rc; int rc;
...@@ -488,148 +406,60 @@ static int initializeSchema(sqlite3* db) ...@@ -488,148 +406,60 @@ static int initializeSchema(sqlite3* db)
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// static void writeInnerClasses(sqlite3*db,const ClassSDict *cl)
static void generateSqlite3ForNamespace(sqlite3 *db, NamespaceDef *nd)
{ {
// + contained class definitions if (!cl) return;
// + contained namespace definitions
// + member groups
// + normal members
// - brief desc
// - detailed desc
// - location
// - files containing (parts of) the namespace definition
if (nd->isReference() || nd->isHidden()) return; // skip external references
// + contained class definitions
writeInnerClasses(db,nd->getClassSDict());
// + contained namespace definitions
writeInnerNamespaces(db,nd->getNamespaceSDict());
// + member groups
if (nd->getMemberGroupSDict())
{
MemberGroupSDict::Iterator mgli(*nd->getMemberGroupSDict());
MemberGroup *mg;
for (;(mg=mgli.current());++mgli)
{
generateSqlite3Section(db,nd,mg->members(),"user-defined",mg->header(),
mg->documentation());
}
}
// + normal members ClassSDict::Iterator cli(*cl);
QListIterator<MemberList> mli(nd->getMemberLists()); ClassDef *cd;
MemberList *ml; for (cli.toFirst();(cd=cli.current());++cli)
for (mli.toFirst();(ml=mli.current());++mli)
{ {
if ((ml->listType()&MemberListType_declarationLists)!=0) if (!cd->isHidden() && cd->name().find('@')==-1) // skip anonymous scopes
{ {
generateSqlite3Section(db,nd,ml,"user-defined");//g_xmlSectionMapper.find(ml->listType())); bindTextParameter(i_s_innerclass,":refid",cd->getOutputFileBase());
bindIntParameter(i_s_innerclass,":prot",cd->protection());
bindTextParameter(i_s_innerclass,":name",cd->name());
if (-1==step(db,i_s_innerclass))
return;
} }
} }
} }
static void writeInnerNamespaces(sqlite3 * /*db*/,const NamespaceSDict *nl)
static void generateSqlite3ForFile(sqlite3 *db, FileDef *fd)
{ {
// + includes files #warning WorkInProgress
// + includedby files if (nl)
// - include graph
// - included by graph
// + contained class definitions
// + contained namespace definitions
// + member groups
// + normal members
// - brief desc
// - detailed desc
// - source code
// - location
// - number of lines
if (fd->isReference()) return; // skip external references
// + includes files
IncludeInfo *ii;
if (fd->includeFileList())
{
QListIterator<IncludeInfo> ili(*fd->includeFileList());
for (ili.toFirst();(ii=ili.current());++ili)
{
int id_file=insertFile(db,fd->absFilePath().data());
bindIntParameter(i_s_includes,":local",ii->local);
bindIntParameter(i_s_includes,":id_src",id_file);
bindTextParameter(i_s_includes,":dst",ii->includeName.data(),FALSE);
if (-1==step(db,i_s_includes))
return;
}
}
// + includedby files
if (fd->includedByFileList())
{
QListIterator<IncludeInfo> ili(*fd->includedByFileList());
for (ili.toFirst();(ii=ili.current());++ili)
{
int id_file=insertFile(db,ii->includeName);
bindIntParameter(i_s_includes,":local",ii->local);
bindIntParameter(i_s_includes,":id_src",id_file);
bindTextParameter(i_s_includes,":dst",fd->absFilePath().data(),FALSE);
if (-1==step(db,i_s_includes))
return;
}
}
// + contained class definitions
if (fd->getClassSDict())
{
writeInnerClasses(db,fd->getClassSDict());
}
// + contained namespace definitions
if (fd->getNamespaceSDict())
{ {
writeInnerNamespaces(db,fd->getNamespaceSDict()); NamespaceSDict::Iterator nli(*nl);
} NamespaceDef *nd;
for (nli.toFirst();(nd=nli.current());++nli)
// + member groups
if (fd->getMemberGroupSDict())
{ {
MemberGroupSDict::Iterator mgli(*fd->getMemberGroupSDict()); if (!nd->isHidden() && nd->name().find('@')==-1) // skip anonymouse scopes
MemberGroup *mg;
for (;(mg=mgli.current());++mgli)
{ {
generateSqlite3Section(db,fd,mg->members(),"user-defined",mg->header(), // t << " <innernamespace refid=\"" << nd->getOutputFileBase()
mg->documentation()); // << "\">" << convertToXML(nd->name()) << "</innernamespace>" << endl;
}
} }
// + normal members
QListIterator<MemberList> mli(fd->getMemberLists());
MemberList *ml;
for (mli.toFirst();(ml=mli.current());++mli)
{
if ((ml->listType()&MemberListType_declarationLists)!=0)
{
generateSqlite3Section(db,fd,ml,"user-defined");//g_xmlSectionMapper.find(ml->listType()));
} }
} }
} }
static void generateSqlite3ForGroup(sqlite3*db,GroupDef *gd)
{ static void writeTemplateArgumentList(sqlite3* /*db*/,
db=db; ArgumentList * /*al*/,
gd=gd; Definition * /*scope*/,
} FileDef * /*fileScope*/,
static void generateSqlite3ForDir(sqlite3 *db,DirDef *dd) int /*indent*/)
{ {
#warning WorkInProgress
} }
static void generateSqlite3ForPage(sqlite3 *db,PageDef *pd,bool isExample)
static void writeTemplateList(sqlite3*db,ClassDef *cd)
{ {
writeTemplateArgumentList(db,cd->templateArguments(),cd,0,4);
} }
////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def)
{ {
// + declaration/definition arg lists // + declaration/definition arg lists
...@@ -645,6 +475,7 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) ...@@ -645,6 +475,7 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def)
// + template arguments // + template arguments
// (templateArguments(), definitionTemplateParameterLists()) // (templateArguments(), definitionTemplateParameterLists())
// - call graph // - call graph
msg("=====%s\n",md->name().data());
// enum values are written as part of the enum // enum values are written as part of the enum
if (md->memberType()==MemberType_EnumValue) return; if (md->memberType()==MemberType_EnumValue) return;
...@@ -911,6 +742,38 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) ...@@ -911,6 +742,38 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def)
} }
} }
static void generateSqlite3Section(sqlite3*db,
Definition *d,
MemberList *ml,const char * /*kind*/,const char * /*header*/=0,
const char * /*documentation*/=0)
{
if (ml==0) return;
MemberListIterator mli(*ml);
MemberDef *md;
int count=0;
for (mli.toFirst();(md=mli.current());++mli)
{
msg("I:%s\n",md->name().data());
// namespace members are also inserted in the file scope, but
// to prevent this duplication in the XML output, we filter those here.
if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==0)
{
count++;
}
}
if (count==0) return; // empty list
for (mli.toFirst();(md=mli.current());++mli)
{
// namespace members are also inserted in the file scope, but
// to prevent this duplication in the XML output, we filter those here.
//if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==0)
{
generateSqlite3ForMember(db,md,d);
}
}
}
static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd) static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd)
{ {
// + list of direct super classes // + list of direct super classes
...@@ -1050,6 +913,146 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd) ...@@ -1050,6 +913,146 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd)
} }
} }
static void generateSqlite3ForNamespace(sqlite3 *db, NamespaceDef *nd)
{
// + contained class definitions
// + contained namespace definitions
// + member groups
// + normal members
// - brief desc
// - detailed desc
// - location
// - files containing (parts of) the namespace definition
if (nd->isReference() || nd->isHidden()) return; // skip external references
// + contained class definitions
writeInnerClasses(db,nd->getClassSDict());
// + contained namespace definitions
writeInnerNamespaces(db,nd->getNamespaceSDict());
// + member groups
if (nd->getMemberGroupSDict())
{
MemberGroupSDict::Iterator mgli(*nd->getMemberGroupSDict());
MemberGroup *mg;
for (;(mg=mgli.current());++mgli)
{
generateSqlite3Section(db,nd,mg->members(),"user-defined",mg->header(),
mg->documentation());
}
}
// + normal members
QListIterator<MemberList> mli(nd->getMemberLists());
MemberList *ml;
for (mli.toFirst();(ml=mli.current());++mli)
{
if ((ml->listType()&MemberListType_declarationLists)!=0)
{
generateSqlite3Section(db,nd,ml,"user-defined");//g_xmlSectionMapper.find(ml->listType()));
}
}
}
static void generateSqlite3ForFile(sqlite3 *db, FileDef *fd)
{
// + includes files
// + includedby files
// - include graph
// - included by graph
// + contained class definitions
// + contained namespace definitions
// + member groups
// + normal members
// - brief desc
// - detailed desc
// - source code
// - location
// - number of lines
if (fd->isReference()) return; // skip external references
// + includes files
IncludeInfo *ii;
if (fd->includeFileList())
{
QListIterator<IncludeInfo> ili(*fd->includeFileList());
for (ili.toFirst();(ii=ili.current());++ili)
{
int id_file=insertFile(db,fd->absFilePath().data());
bindIntParameter(i_s_includes,":local",ii->local);
bindIntParameter(i_s_includes,":id_src",id_file);
bindTextParameter(i_s_includes,":dst",ii->includeName.data(),FALSE);
if (-1==step(db,i_s_includes))
return;
}
}
// + includedby files
if (fd->includedByFileList())
{
QListIterator<IncludeInfo> ili(*fd->includedByFileList());
for (ili.toFirst();(ii=ili.current());++ili)
{
int id_file=insertFile(db,ii->includeName);
bindIntParameter(i_s_includes,":local",ii->local);
bindIntParameter(i_s_includes,":id_src",id_file);
bindTextParameter(i_s_includes,":dst",fd->absFilePath().data(),FALSE);
if (-1==step(db,i_s_includes))
return;
}
}
// + contained class definitions
if (fd->getClassSDict())
{
writeInnerClasses(db,fd->getClassSDict());
}
// + contained namespace definitions
if (fd->getNamespaceSDict())
{
writeInnerNamespaces(db,fd->getNamespaceSDict());
}
// + member groups
if (fd->getMemberGroupSDict())
{
MemberGroupSDict::Iterator mgli(*fd->getMemberGroupSDict());
MemberGroup *mg;
for (;(mg=mgli.current());++mgli)
{
generateSqlite3Section(db,fd,mg->members(),"user-defined",mg->header(),
mg->documentation());
}
}
// + normal members
QListIterator<MemberList> mli(fd->getMemberLists());
MemberList *ml;
for (mli.toFirst();(ml=mli.current());++mli)
{
if ((ml->listType()&MemberListType_declarationLists)!=0)
{
generateSqlite3Section(db,fd,ml,"user-defined");//g_xmlSectionMapper.find(ml->listType()));
}
}
}
static void generateSqlite3ForGroup(sqlite3*db,GroupDef *gd)
{
db=db;
gd=gd;
}
static void generateSqlite3ForDir(sqlite3 *db,DirDef *dd)
{
}
static void generateSqlite3ForPage(sqlite3 *db,PageDef *pd,bool isExample)
{
}
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void generateSqlite3() void generateSqlite3()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment