From bac76c1957de71e3e0bddc23ccd46b7b2537c8a1 Mon Sep 17 00:00:00 2001 From: Adrian Negreanu Date: Fri, 5 Aug 2016 23:18:05 +0300 Subject: sqlite3gen: insert xrefs using integer refids --- src/sqlite3gen.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index 5a86073..c9ee444 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -400,11 +400,9 @@ static int insertRefid(sqlite3 *db, const char *refid) } -static void insertMemberReference(sqlite3 *db, const char*src, const char*dst, const char *file, int line, int column) +static void insertMemberReference(sqlite3 *db, int refid_src, int refid_dst, + int id_file, int line, int column) { - int id_file = insertFile(db,file); - int refid_src = insertRefid(db,src); - int refid_dst = insertRefid(db,dst); if (id_file==-1||refid_src==-1||refid_dst==-1) return; @@ -412,26 +410,20 @@ static void insertMemberReference(sqlite3 *db, const char*src, const char*dst, c bindIntParameter(xrefs_insert,":refid_dst",refid_dst); bindIntParameter(xrefs_insert,":id_file",id_file); bindIntParameter(xrefs_insert,":line",line); - bindIntParameter(xrefs_insert,":column",1); + bindIntParameter(xrefs_insert,":column",column); step(db,xrefs_insert); } -static void insertMemberReference(sqlite3 *db, MemberDef *src, MemberDef *dst, const char*floc) +static void insertMemberReference(sqlite3 *db, MemberDef *src, MemberDef *dst) { + QCString qrefid_dst = dst->getOutputFileBase() + "_1" + dst->anchor(); + QCString qrefid_src = src->getOutputFileBase() + "_1" + src->anchor(); if (dst->getStartBodyLine()!=-1 && dst->getBodyDef()) { - static char file[4096]; - int line=0,column=0; - if (floc) - { - int rv = sscanf(floc,"%[^:]:%d:%d",file,&line,&column); - if (rv!=3) - { - msg("unable to read file:line:col location from string [%s]\n",floc); - return; - } - } - insertMemberReference(db,src->anchor().data(),dst->anchor().data(),file,line,column); + int refid_src = insertRefid(db,qrefid_src.data()); + int refid_dst = insertRefid(db,qrefid_dst.data()); + int id_file = insertFile(db,"no-file"); // TODO: replace no-file with proper file + insertMemberReference(db,refid_src,refid_dst,id_file,dst->getStartBodyLine(),-1); } } @@ -462,7 +454,11 @@ static void insertMemberFunctionParams(sqlite3 *db,int id_memberdef,MemberDef *m QCString *s; while ((s=li.current())) { - insertMemberReference(db,md->anchor().data(),s->data(),def->getDefFileName().data(),md->getDefLine(),1); + QCString qrefid_src = md->getOutputFileBase() + "_1" + md->anchor(); + int refid_src = insertRefid(db,qrefid_src.data()); + int refid_dst = insertRefid(db,s->data()); + int id_file = insertFile(db,def->getDefFileName()); + insertMemberReference(db,refid_src,refid_dst,id_file,md->getDefLine(),-1); ++li; } bindTextParameter(params_select,":type",a->type.data()); @@ -874,7 +870,11 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) s->data(), md->getBodyDef()->getDefFileName().data(), md->getStartBodyLine())); - insertMemberReference(db,md->anchor().data(),s->data(),md->getBodyDef()->getDefFileName().data(),md->getStartBodyLine(),1); + QCString qrefid_src = md->getOutputFileBase() + "_1" + md->anchor(); + int refid_src = insertRefid(db,qrefid_src.data()); + int refid_dst = insertRefid(db,s->data()); + int id_file = insertFile(db,md->getBodyDef()->getDefFileName()); + insertMemberReference(db,refid_src,refid_dst,id_file,md->getStartBodyLine(),-1); } ++li; } @@ -939,7 +939,7 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) MemberDef *rmd; for (mdi.toFirst();(rmd=mdi.current());++mdi) { - insertMemberReference(db,md,rmd,mdi.currentKey()); + insertMemberReference(db,md,rmd);//,mdi.currentKey()); } } // + source referenced by @@ -950,7 +950,7 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) MemberDef *rmd; for (mdi.toFirst();(rmd=mdi.current());++mdi) { - insertMemberReference(db,rmd,md,mdi.currentKey()); + insertMemberReference(db,rmd,md);//,mdi.currentKey()); } } } -- cgit v0.12 From 8208b2d5514a3c29659ae967da544adc21585212 Mon Sep 17 00:00:00 2001 From: Adrian Negreanu Date: Tue, 9 Aug 2016 17:37:50 +0300 Subject: sqlite3gen: sync with xmlgen Modified the memberdef table so that it includes all elements xmlgen dups for a memberdef. --- src/sqlite3gen.cpp | 255 +++++++++++++++++++++++++++++++++++++++++------------ src/xmlgen.cpp | 1 + 2 files changed, 200 insertions(+), 56 deletions(-) diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index c9ee444..8c95e75 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -92,47 +92,64 @@ const char * schema_queries[][2] = { { "memberdef", "CREATE TABLE IF NOT EXISTS memberdef (\n" "\t-- All processed identifiers.\n" - "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" - "\tid_file INTEGER NOT NULL, -- file where this identifier is located\n" - "\tline INTEGER NOT NULL, -- line where this identifier is located\n" - "\tcolumn INTEGER NOT NULL, -- column where this identifier is located\n" - "\trefid INTEGER NOT NULL, -- see the refids table\n" - "\tname TEXT NOT NULL,\n" - "\tdefinition TEXT,\n" - "\ttype TEXT,\n" - "\targsstring TEXT,\n" - "\tscope TEXT,\n" - "\tinitializer TEXT,\n" - "\tprot INTEGER DEFAULT 0, -- 0:public 1:protected 2:private 3:package\n" - "\tconst INTEGER DEFAULT 0, -- 0:non-constant 1:constant\n" - "\tvirt INTEGER DEFAULT 0, -- 0:non-virtual 1:virtual 2:pure-virtual\n" - "\tstatic INTEGER DEFAULT 0, -- 0:non-static 1:static\n" - "\texplicit INTEGER DEFAULT 0,\n" - "\tinline INTEGER DEFAULT 0,\n" - "\tfinal INTEGER DEFAULT 0,\n" - "\tsealed INTEGER DEFAULT 0,\n" - "\tnew INTEGER DEFAULT 0,\n" - "\toptional INTEGER DEFAULT 0,\n" - "\trequired INTEGER DEFAULT 0,\n" - "\tmutable INTEGER DEFAULT 0,\n" - "\tinitonly INTEGER DEFAULT 0,\n" - "\treadable INTEGER DEFAULT 0,\n" - "\twritable INTEGER DEFAULT 0,\n" - "\tgettable INTEGER DEFAULT 0,\n" - "\tsettable INTEGER DEFAULT 0,\n" - "\taccessor INTEGER DEFAULT 0,\n" - "\taddable INTEGER DEFAULT 0,\n" - "\tremovable INTEGER DEFAULT 0,\n" - "\traisable INTEGER DEFAULT 0,\n" + "\trowid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n" + "\trefid INTEGER NOT NULL, -- see the refids table\n" + "\tname TEXT NOT NULL,\n" + "\tdefinition TEXT,\n" + "\ttype TEXT,\n" + "\targsstring TEXT,\n" + "\tscope TEXT,\n" + "\tinitializer TEXT,\n" + "\tbitfield TEXT,\n" + "\tread TEXT,\n" + "\twrite TEXT,\n" + "\tprot INTEGER DEFAULT 0, -- 0:public 1:protected 2:private 3:package\n" + "\tstatic INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tconst INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\texplicit INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tinline INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tfinal INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tsealed INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tnew INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\toptional INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\trequired INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tvolatile INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tvirt INTEGER DEFAULT 0, -- 0:no 1:virtual 2:pure-virtual\n" + "\tmutable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tinitonly INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tattribute INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tproperty INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\treadonly INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tbound INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tconstrained INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\ttransient INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tmaybevoid INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tmaybedefault INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tmaybeambiguous INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\treadable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\twritable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tgettable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tprivategettable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tprotectedgettable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tsettable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tprivatesettable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tprotectedsettable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\taccessor INTEGER DEFAULT 0, -- 0:no 1:assign 2:copy 3:retain 4:string 5:weak\n" + "\taddable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\tremovable INTEGER DEFAULT 0, -- 0:no 1:yes\n" + "\traisable INTEGER DEFAULT 0, -- 0:no 1:yes\n" /// @todo make a `kind' table - "\tkind INTEGER DEFAULT 0, -- 0:define 1:function 2:variable 3:typedef 4:enum 5:enumvalue 6:signal 7:slot 8:friend 9:DCOP 10:property 11:event\n" - "\tid_bodyfile INTEGER DEFAULT 0, -- file of definition\n" - "\tbodystart INTEGER DEFAULT 0, -- starting line of definition\n" - "\tbodyend INTEGER DEFAULT 0, -- ending line of definition\n" + "\tkind INTEGER DEFAULT 0, -- 0:define 1:function 2:variable 3:typedef 4:enum 5:enumvalue 6:signal 7:slot 8:friend 9:DCOP 10:property 11:event\n" + "\tbodystart INTEGER DEFAULT 0, -- starting line of definition\n" + "\tbodyend INTEGER DEFAULT 0, -- ending line of definition\n" + "\tid_bodyfile INTEGER DEFAULT 0, -- file of definition\n" + "\tid_file INTEGER NOT NULL, -- file where this identifier is located\n" + "\tline INTEGER NOT NULL, -- line where this identifier is located\n" + "\tcolumn INTEGER NOT NULL, -- column where this identifier is located\n" /// @todo make a `detaileddescription' table "\tdetaileddescription TEXT,\n" "\tbriefdescription TEXT,\n" - "\tinbodydescription TEXTi\n" + "\tinbodydescription TEXT\n" ");" }, { "compounddef", @@ -251,9 +268,121 @@ SqlStmt xrefs_insert= {"INSERT INTO xrefs " }; ////////////////////////////////////////////////////// SqlStmt memberdef_insert={"INSERT INTO memberdef " - "( refid, prot, static, const, explicit, inline, final, sealed, new, optional, required, virt, mutable, initonly, readable, writable, gettable, settable, accessor, addable, removable, raisable, name, type, definition, argsstring, scope, initializer, kind, id_bodyfile, bodystart, bodyend, id_file, line, column, detaileddescription, briefdescription, inbodydescription)" + "(" + "refid," + "name," + "definition," + "type," + "argsstring," + "scope," + "initializer," + "bitfield," + "read," + "write," + "prot," + "static," + "const," + "explicit," + "inline," + "final," + "sealed," + "new," + "optional," + "required," + "volatile," + "virt," + "mutable," + "initonly," + "attribute," + "property," + "readonly," + "bound," + "constrained," + "transient," + "maybevoid," + "maybedefault," + "maybeambiguous," + "readable," + "writable," + "gettable," + "protectedsettable," + "protectedgettable," + "settable," + "privatesettable," + "privategettable," + "accessor," + "addable," + "removable," + "raisable," + "kind," + "bodystart," + "bodyend," + "id_bodyfile," + "id_file," + "line," + "column," + "detaileddescription," + "briefdescription," + "inbodydescription" + ")" "VALUES " - "(:refid,:prot,:static,:const,:explicit,:inline,:final,:sealed,:new,:optional,:required,:virt,:mutable,:initonly,:readable,:writable,:gettable,:settable,:accessor,:addable,:removable,:raisable,:name,:type,:definition,:argsstring,:scope,:initializer,:kind,:id_bodyfile,:bodystart,:bodyend,:id_file,:line,:column,:detaileddescription,:briefdescription,:inbodydescription)" + "(" + ":refid," + ":name," + ":definition," + ":type," + ":argsstring," + ":scope," + ":initializer," + ":bitfield," + ":read," + ":write," + ":prot," + ":static," + ":const," + ":explicit," + ":inline," + ":final," + ":sealed," + ":new," + ":optional," + ":required," + ":volatile," + ":virt," + ":mutable," + ":initonly," + ":attribute," + ":property," + ":readonly," + ":bound," + ":constrained," + ":transient," + ":maybevoid," + ":maybedefault," + ":maybeambiguous," + ":readable," + ":writable," + ":gettable," + ":privategettable," + ":protectedgettable," + ":settable," + ":privatesettable," + ":privategettable," + ":accessor," + ":addable," + ":removable," + ":raisable," + ":kind," + ":bodystart," + ":bodyend," + ":id_bodyfile," + ":id_file," + ":line," + ":column," + ":detaileddescription," + ":briefdescription," + ":inbodydescription" + ")" ,NULL }; ////////////////////////////////////////////////////// @@ -769,6 +898,7 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) if (al!=0) { bindIntParameter(memberdef_insert,":const",al->constSpecifier); + bindIntParameter(memberdef_insert,":volatile",al->volatileSpecifier); } bindIntParameter(memberdef_insert,":explicit",md->isExplicit()); bindIntParameter(memberdef_insert,":inline",md->isInline()); @@ -780,26 +910,52 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) bindIntParameter(memberdef_insert,":virt",md->virtualness()); } - // place in the arguments and linkify the arguments if (md->memberType() == MemberType_Variable) { bindIntParameter(memberdef_insert,":mutable",md->isMutable()); bindIntParameter(memberdef_insert,":initonly",md->isInitonly()); + bindIntParameter(memberdef_insert,":attribute",md->isAttribute()); + bindIntParameter(memberdef_insert,":property",md->isProperty()); + bindIntParameter(memberdef_insert,":readonly",md->isReadonly()); + bindIntParameter(memberdef_insert,":bound",md->isBound()); + bindIntParameter(memberdef_insert,":removable",md->isRemovable()); + bindIntParameter(memberdef_insert,":constrained",md->isConstrained()); + bindIntParameter(memberdef_insert,":transient",md->isTransient()); + bindIntParameter(memberdef_insert,":maybevoid",md->isMaybeVoid()); + bindIntParameter(memberdef_insert,":maybedefault",md->isMaybeDefault()); + bindIntParameter(memberdef_insert,":maybeambiguous",md->isMaybeAmbiguous()); + if (md->bitfieldString()) + { + QCString bitfield = md->bitfieldString(); + if (bitfield.at(0)==':') bitfield=bitfield.mid(1); + bindTextParameter(memberdef_insert,":bitfield",bitfield); + } } else if (md->memberType() == MemberType_Property) { bindIntParameter(memberdef_insert,":readable",md->isReadable()); bindIntParameter(memberdef_insert,":writable",md->isWritable()); bindIntParameter(memberdef_insert,":gettable",md->isGettable()); + bindIntParameter(memberdef_insert,":privategettable",md->isPrivateGettable()); + bindIntParameter(memberdef_insert,":protectedgettable",md->isProtectedGettable()); bindIntParameter(memberdef_insert,":settable",md->isSettable()); - if (md->isAssign() || md->isCopy() || md->isRetain()) + bindIntParameter(memberdef_insert,":privatesettable",md->isPrivateSettable()); + bindIntParameter(memberdef_insert,":protectedsettable",md->isProtectedSettable()); + if (md->isAssign() || md->isCopy() || md->isRetain() + || md->isStrong() || md->isWeak()) { - int accessor = md->isAssign() ? md->isAssign() : - (md->isCopy() ? md->isCopy() : md->isRetain()) ; + int accessor=0; + if (md->isAssign()) accessor = 1; + else if (md->isCopy()) accessor = 2; + else if (md->isRetain()) accessor = 3; + else if (md->isStrong()) accessor = 4; + else if (md->isWeak()) accessor = 5; bindIntParameter(memberdef_insert,":accessor",accessor); } + bindTextParameter(memberdef_insert,":read",md->getReadAccessor()); + bindTextParameter(memberdef_insert,":write",md->getWriteAccessor()); } else if (md->memberType() == MemberType_Event) { @@ -839,19 +995,6 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) bindTextParameter(memberdef_insert,":name",md->name()); - if (md->memberType() == MemberType_Property) - { - if (md->isReadable()) - { - bindIntParameter(memberdef_insert,":readable",1); - } - if (md->isWritable()) - { - bindIntParameter(memberdef_insert,":writable",1); - } - } - - // Extract references from initializer if (md->hasMultiLineInitializer() || md->hasOneLineInitializer()) { diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index 1551727..a00c17e 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -804,6 +804,7 @@ static void generateXMLForMember(MemberDef *md,FTextStream &ti,FTextStream &t,De if (md->isWritable()) t << " " << convertToXML(md->getWriteAccessor()) << "" << endl; } + if (md->memberType()==MemberType_Variable && md->bitfieldString()) { QCString bitfield = md->bitfieldString(); -- cgit v0.12 From 87222afcfe6089899c8ded60b23692fd40997856 Mon Sep 17 00:00:00 2001 From: Adrian Negreanu Date: Tue, 9 Aug 2016 19:19:18 +0300 Subject: sqlite3gen: stripFromPath on all calls to insertFile --- src/sqlite3gen.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index 8c95e75..54fca28 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -586,7 +586,7 @@ static void insertMemberFunctionParams(sqlite3 *db,int id_memberdef,MemberDef *m QCString qrefid_src = md->getOutputFileBase() + "_1" + md->anchor(); int refid_src = insertRefid(db,qrefid_src.data()); int refid_dst = insertRefid(db,s->data()); - int id_file = insertFile(db,def->getDefFileName()); + int id_file = insertFile(db,stripFromPath(def->getDefFileName())); insertMemberReference(db,refid_src,refid_dst,id_file,md->getDefLine(),-1); ++li; } @@ -1016,7 +1016,7 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) QCString qrefid_src = md->getOutputFileBase() + "_1" + md->anchor(); int refid_src = insertRefid(db,qrefid_src.data()); int refid_dst = insertRefid(db,s->data()); - int id_file = insertFile(db,md->getBodyDef()->getDefFileName()); + int id_file = insertFile(db,stripFromPath(md->getBodyDef()->getDefFileName())); insertMemberReference(db,refid_src,refid_dst,id_file,md->getStartBodyLine(),-1); } ++li; @@ -1036,7 +1036,7 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) // File location if (md->getDefLine() != -1) { - int id_file = insertFile(db,md->getDefFileName()); + int id_file = insertFile(db,stripFromPath(md->getDefFileName())); if (id_file!=-1) { bindIntParameter(memberdef_insert,":id_file",id_file); @@ -1045,7 +1045,7 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) if (md->getStartBodyLine()!=-1) { - int id_bodyfile = insertFile(db,md->getBodyDef()->absFilePath()); + int id_bodyfile = insertFile(db,stripFromPath(md->getBodyDef()->absFilePath())); if (id_bodyfile == -1) { sqlite3_clear_bindings(memberdef_insert.stmt); @@ -1160,7 +1160,7 @@ static void generateSqlite3ForClass(sqlite3 *db, ClassDef *cd) int refid = insertRefid(db, cd->getOutputFileBase()); bindIntParameter(compounddef_insert,":refid", refid); - int id_file = insertFile(db,cd->getDefFileName().data()); + int id_file = insertFile(db,stripFromPath(cd->getDefFileName())); bindIntParameter(compounddef_insert,":id_file",id_file); bindIntParameter(compounddef_insert,":line",cd->getDefLine()); bindIntParameter(compounddef_insert,":column",cd->getDefColumn()); -- cgit v0.12 From 6f4561608adaf8230c2fa015770dfeeab5ce3ba8 Mon Sep 17 00:00:00 2001 From: Adrian Negreanu Date: Tue, 9 Aug 2016 19:31:58 +0300 Subject: sqlite3gen: stripWhitespace on bitfield's text --- src/sqlite3gen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index 54fca28..6bc8789 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -929,7 +929,7 @@ static void generateSqlite3ForMember(sqlite3*db,MemberDef *md,Definition *def) { QCString bitfield = md->bitfieldString(); if (bitfield.at(0)==':') bitfield=bitfield.mid(1); - bindTextParameter(memberdef_insert,":bitfield",bitfield); + bindTextParameter(memberdef_insert,":bitfield",bitfield.stripWhiteSpace()); } } else if (md->memberType() == MemberType_Property) -- cgit v0.12