Commit 00b7d393 authored by Dimitri van Heesch's avatar Dimitri van Heesch

More context and template additions

parent 727e5e1c
...@@ -2446,12 +2446,12 @@ bool ClassDef::addExample(const char *anchor,const char *nameStr, ...@@ -2446,12 +2446,12 @@ bool ClassDef::addExample(const char *anchor,const char *nameStr,
} }
// returns TRUE if this class is used in an example // returns TRUE if this class is used in an example
bool ClassDef::hasExamples() bool ClassDef::hasExamples() const
{ {
if (m_impl->exampleSDict==0) bool result=FALSE;
return FALSE; if (m_impl->exampleSDict)
else result = m_impl->exampleSDict->count()>0;
return m_impl->exampleSDict->count()>0; return result;
} }
...@@ -4758,3 +4758,12 @@ const FileList &ClassDef::usedFiles() const ...@@ -4758,3 +4758,12 @@ const FileList &ClassDef::usedFiles() const
return m_impl->files; return m_impl->files;
} }
const ArgumentList *ClassDef::typeConstraints() const
{
return m_impl->typeConstraints;
}
const ExampleSDict *ClassDef::exampleList() const
{
return m_impl->exampleSDict;
}
...@@ -313,6 +313,11 @@ class ClassDef : public Definition ...@@ -313,6 +313,11 @@ class ClassDef : public Definition
QCString includeStatement() const; QCString includeStatement() const;
const ArgumentList *typeConstraints() const;
const ExampleSDict *exampleList() const;
bool hasExamples() const;
QCString getMemberListFileName() const;
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// --- setters ---- // --- setters ----
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
...@@ -384,7 +389,6 @@ class ClassDef : public Definition ...@@ -384,7 +389,6 @@ class ClassDef : public Definition
protected: protected:
void addUsedInterfaceClasses(MemberDef *md,const char *typeStr); void addUsedInterfaceClasses(MemberDef *md,const char *typeStr);
bool hasExamples();
bool hasNonReferenceSuperClass(); bool hasNonReferenceSuperClass();
void showUsedFiles(OutputList &ol); void showUsedFiles(OutputList &ol);
...@@ -392,7 +396,6 @@ class ClassDef : public Definition ...@@ -392,7 +396,6 @@ class ClassDef : public Definition
void writeTagFileMarker(); void writeTagFileMarker();
void writeDocumentationContents(OutputList &ol,const QCString &pageTitle); void writeDocumentationContents(OutputList &ol,const QCString &pageTitle);
void internalInsertMember(MemberDef *md,Protection prot,bool addToAllList); void internalInsertMember(MemberDef *md,Protection prot,bool addToAllList);
QCString getMemberListFileName() const;
void addMemberToList(MemberListType lt,MemberDef *md,bool isBrief); void addMemberToList(MemberListType lt,MemberDef *md,bool isBrief);
MemberList *createMemberList(MemberListType lt); MemberList *createMemberList(MemberListType lt);
void writeInheritedMemberDeclarations(OutputList &ol,MemberListType lt,int lt2,const QCString &title,ClassDef *inheritedFrom,bool invert,bool showAlways,QPtrDict<void> *visitedClasses); void writeInheritedMemberDeclarations(OutputList &ol,MemberListType lt,int lt2,const QCString &title,ClassDef *inheritedFrom,bool invert,bool showAlways,QPtrDict<void> *visitedClasses);
......
This diff is collapsed.
...@@ -28,6 +28,8 @@ class MemberList; ...@@ -28,6 +28,8 @@ class MemberList;
class MemberDef; class MemberDef;
struct Argument; struct Argument;
class ArgumentList; class ArgumentList;
class MemberNameInfoSDict;
struct MemberInfo;
//---------------------------------------------------- //----------------------------------------------------
...@@ -679,10 +681,44 @@ class MemberListInfoContext : public TemplateStructIntf ...@@ -679,10 +681,44 @@ class MemberListInfoContext : public TemplateStructIntf
//---------------------------------------------------- //----------------------------------------------------
class MemberInfoContext : public TemplateStructIntf
{
public:
MemberInfoContext(const MemberInfo *mi);
~MemberInfoContext();
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
private:
class Private;
Private *p;
};
//----------------------------------------------------
class AllMembersListContext : public TemplateListIntf
{
public:
AllMembersListContext(const MemberNameInfoSDict *ml);
~AllMembersListContext();
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
private:
class Private;
Private *p;
};
//----------------------------------------------------
class ArgumentContext : public TemplateStructIntf class ArgumentContext : public TemplateStructIntf
{ {
public: public:
ArgumentContext(const Argument *arg); ArgumentContext(const Argument *arg,Definition *def,const QCString &relPath);
~ArgumentContext(); ~ArgumentContext();
// TemplateStructIntf methods // TemplateStructIntf methods
...@@ -698,7 +734,7 @@ class ArgumentContext : public TemplateStructIntf ...@@ -698,7 +734,7 @@ class ArgumentContext : public TemplateStructIntf
class ArgumentListContext : public TemplateListIntf class ArgumentListContext : public TemplateListIntf
{ {
public: public:
ArgumentListContext(const ArgumentList *al); ArgumentListContext(const ArgumentList *al,Definition *def,const QCString &relPath);
~ArgumentListContext(); ~ArgumentListContext();
// TemplateListIntf // TemplateListIntf
......
...@@ -959,7 +959,7 @@ void Definition::writeSourceDef(OutputList &ol,const char *) ...@@ -959,7 +959,7 @@ void Definition::writeSourceDef(OutputList &ol,const char *)
{ {
ol.disable(OutputGenerator::Latex); ol.disable(OutputGenerator::Latex);
} }
// write line link (HTML, LaTeX optionally) // write file link (HTML, LaTeX optionally)
ol.writeObjectLink(0,fn,0,m_impl->body->fileDef->name()); ol.writeObjectLink(0,fn,0,m_impl->body->fileDef->name());
ol.enableAll(); ol.enableAll();
ol.disable(OutputGenerator::Html); ol.disable(OutputGenerator::Html);
......
...@@ -3279,7 +3279,7 @@ void HtmlGenerator::writeExternalSearchPage() ...@@ -3279,7 +3279,7 @@ void HtmlGenerator::writeExternalSearchPage()
void HtmlGenerator::startConstraintList(const char *header) void HtmlGenerator::startConstraintList(const char *header)
{ {
t << "<div class=\"typeconstraint\">" << endl; t << "<div class=\"typeconstraint\">" << endl;
t << "<dl><dt><b>" << header << "</b><dt><dd>" << endl; t << "<dl><dt><b>" << header << "</b></dt><dd>" << endl;
t << "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">" << endl; t << "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">" << endl;
} }
......
...@@ -128,7 +128,6 @@ static bool writeDefArgumentList(OutputList &ol,ClassDef *cd, ...@@ -128,7 +128,6 @@ static bool writeDefArgumentList(OutputList &ol,ClassDef *cd,
{ {
return FALSE; // member has no function like argument list return FALSE; // member has no function like argument list
} }
if (!md->isDefine()) ol.docify(" ");
// simple argument list for tcl // simple argument list for tcl
if (md->getLanguage()==SrcLangExt_Tcl) if (md->getLanguage()==SrcLangExt_Tcl)
...@@ -156,6 +155,8 @@ static bool writeDefArgumentList(OutputList &ol,ClassDef *cd, ...@@ -156,6 +155,8 @@ static bool writeDefArgumentList(OutputList &ol,ClassDef *cd,
return TRUE; return TRUE;
} }
if (!md->isDefine()) ol.docify(" ");
//printf("writeDefArgList(%d)\n",defArgList->count()); //printf("writeDefArgList(%d)\n",defArgList->count());
ol.pushGeneratorState(); ol.pushGeneratorState();
//ol.disableAllBut(OutputGenerator::Html); //ol.disableAllBut(OutputGenerator::Html);
...@@ -262,7 +263,7 @@ static bool writeDefArgumentList(OutputList &ol,ClassDef *cd, ...@@ -262,7 +263,7 @@ static bool writeDefArgumentList(OutputList &ol,ClassDef *cd,
{ {
ol.docify(a->type.mid(wp,vp-wp)); ol.docify(a->type.mid(wp,vp-wp));
} }
if (!a->name.isEmpty() || (a->name.isEmpty() && a->type=="...")) // argument has a name if (!a->name.isEmpty() || a->type=="...") // argument has a name
{ {
//if (!hasFuncPtrType) //if (!hasFuncPtrType)
//{ //{
...@@ -1925,7 +1926,7 @@ bool MemberDef::isDetailedSectionVisible(bool inGroup,bool inFile) const ...@@ -1925,7 +1926,7 @@ bool MemberDef::isDetailedSectionVisible(bool inGroup,bool inFile) const
return result; return result;
} }
void MemberDef::_getLabels(QStrList &sl,Definition *container) const void MemberDef::getLabels(QStrList &sl,Definition *container) const
{ {
static bool inlineInfo = Config_getBool("INLINE_INFO"); static bool inlineInfo = Config_getBool("INLINE_INFO");
...@@ -2382,6 +2383,69 @@ void MemberDef::_writeEnumValues(OutputList &ol,Definition *container, ...@@ -2382,6 +2383,69 @@ void MemberDef::_writeEnumValues(OutputList &ol,Definition *container,
} }
} }
QCString MemberDef::displayDefinition() const
{
QCString ldef = definition();
QCString title = name();
if (isEnumerate())
{
if (title.at(0)=='@')
{
ldef = title = "anonymous enum";
if (!m_impl->enumBaseType.isEmpty())
{
ldef+=" : "+m_impl->enumBaseType;
}
}
else
{
ldef.prepend("enum ");
}
}
else if (isEnumValue())
{
if (ldef.at(0)=='@')
{
ldef=ldef.mid(2);
}
}
ClassDef *cd=getClassDef();
if (cd && cd->isObjectiveC())
{
// strip scope name
int ep = ldef.find("::");
if (ep!=-1)
{
int sp=ldef.findRev(' ',ep);
if (sp!=-1)
{
ldef=ldef.left(sp+1)+ldef.mid(ep+2);
}
}
// strip keywords
int dp = ldef.find(':');
if (dp!=-1)
{
ldef=ldef.left(dp+1);
}
int l=ldef.length();
//printf("start >%s<\n",ldef.data());
int i=l-1;
while (i>=0 && (isId(ldef.at(i)) || ldef.at(i)==':')) i--;
while (i>=0 && isspace((uchar)ldef.at(i))) i--;
if (i>0)
{
// insert braches around the type
QCString tmp("("+ldef.left(i+1)+")"+ldef.mid(i+1));
ldef=tmp;
}
//printf("end >%s< i=%d\n",ldef.data(),i);
if (isStatic()) ldef.prepend("+ "); else ldef.prepend("- ");
}
SrcLangExt lang = getLanguage();
QCString sep = getLanguageSpecificSeparator(lang,TRUE);
return substitute(ldef,"::",sep);
}
/*! Writes the "detailed documentation" section of this member to /*! Writes the "detailed documentation" section of this member to
* all active output formats. * all active output formats.
...@@ -2473,7 +2537,7 @@ void MemberDef::writeDocumentation(MemberList *ml,OutputList &ol, ...@@ -2473,7 +2537,7 @@ void MemberDef::writeDocumentation(MemberList *ml,OutputList &ol,
bool htmlEndLabelTable=FALSE; bool htmlEndLabelTable=FALSE;
QStrList sl; QStrList sl;
_getLabels(sl,container); getLabels(sl,container);
if ((isVariable() || isTypedef()) && (i=r.match(ldef,0,&l))!=-1) if ((isVariable() || isTypedef()) && (i=r.match(ldef,0,&l))!=-1)
{ {
......
...@@ -75,6 +75,7 @@ class MemberDef : public Definition ...@@ -75,6 +75,7 @@ class MemberDef : public Definition
int initializerLines() const; int initializerLines() const;
uint64 getMemberSpecifiers() const; uint64 getMemberSpecifiers() const;
MemberList *getSectionList(Definition *d) const; MemberList *getSectionList(Definition *d) const;
QCString displayDefinition() const;
// scope query members // scope query members
ClassDef *getClassDef() const; ClassDef *getClassDef() const;
...@@ -242,6 +243,7 @@ class MemberDef : public Definition ...@@ -242,6 +243,7 @@ class MemberDef : public Definition
QCString displayName(bool=TRUE) const; QCString displayName(bool=TRUE) const;
QCString getDeclType() const; QCString getDeclType() const;
void getLabels(QStrList &sl,Definition *container) const;
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// ---- setters ----- // ---- setters -----
...@@ -384,7 +386,6 @@ class MemberDef : public Definition ...@@ -384,7 +386,6 @@ class MemberDef : public Definition
void _computeLinkableInProject(); void _computeLinkableInProject();
void _computeIsConstructor(); void _computeIsConstructor();
void _computeIsDestructor(); void _computeIsDestructor();
void _getLabels(QStrList &sl,Definition *container) const;
void _writeCallGraph(OutputList &ol); void _writeCallGraph(OutputList &ol);
void _writeCallerGraph(OutputList &ol); void _writeCallerGraph(OutputList &ol);
void _writeReimplements(OutputList &ol); void _writeReimplements(OutputList &ol);
......
...@@ -250,7 +250,7 @@ bool TemplateVariant::toBool() const ...@@ -250,7 +250,7 @@ bool TemplateVariant::toBool() const
result = p->intVal!=0; result = p->intVal!=0;
break; break;
case String: case String:
result = !p->strVal.isEmpty() && p->strVal!="false" && p->strVal!="0"; result = !p->strVal.isEmpty(); // && p->strVal!="false" && p->strVal!="0";
break; break;
case Struct: case Struct:
result = TRUE; result = TRUE;
...@@ -758,6 +758,31 @@ class FilterNoWrap ...@@ -758,6 +758,31 @@ class FilterNoWrap
} }
}; };
//--------------------------------------------------------------------
/** @brief The implementation of the "divisibleby" filter */
class FilterDivisibleBy
{
public:
static TemplateVariant apply(const TemplateVariant &v,const TemplateVariant &n)
{
printf("FilterDivisibleBy::apply()\n");
if (!v.isValid() || !n.isValid())
{
return TemplateVariant();
}
if (v.type()==TemplateVariant::Integer && n.type()==TemplateVariant::Integer)
{
printf("FilterDivisibleBy(%d,%d)=%d",v.toInt(),n.toInt(),(v.toInt()%n.toInt())==0);
return TemplateVariant((v.toInt()%n.toInt())==0);
}
else
{
return TemplateVariant();
}
}
};
//-------------------------------------------------------------------- //--------------------------------------------------------------------
...@@ -809,12 +834,14 @@ class TemplateFilterFactory ...@@ -809,12 +834,14 @@ class TemplateFilterFactory
}; };
// register a handlers for each filter we support // register a handlers for each filter we support
static TemplateFilterFactory::AutoRegister<FilterAdd> fAdd("add"); static TemplateFilterFactory::AutoRegister<FilterAdd> fAdd("add");
static TemplateFilterFactory::AutoRegister<FilterPrepend> fPrepend("prepend"); static TemplateFilterFactory::AutoRegister<FilterAdd> fAppend("append");
static TemplateFilterFactory::AutoRegister<FilterLength> fLength("length"); static TemplateFilterFactory::AutoRegister<FilterLength> fLength("length");
static TemplateFilterFactory::AutoRegister<FilterDefault> fDefault("default"); static TemplateFilterFactory::AutoRegister<FilterNoWrap> fNoWrap("nowrap");
static TemplateFilterFactory::AutoRegister<FilterStripPath> fStripPath("stripPath"); static TemplateFilterFactory::AutoRegister<FilterDefault> fDefault("default");
static TemplateFilterFactory::AutoRegister<FilterNoWrap> fNoWrap("nowrap"); static TemplateFilterFactory::AutoRegister<FilterPrepend> fPrepend("prepend");
static TemplateFilterFactory::AutoRegister<FilterStripPath> fStripPath("stripPath");
static TemplateFilterFactory::AutoRegister<FilterDivisibleBy> fDivisibleBy("divisibleby");
//-------------------------------------------------------------------- //--------------------------------------------------------------------
...@@ -1404,6 +1431,16 @@ class ExpressionParser ...@@ -1404,6 +1431,16 @@ class ExpressionParser
m_curToken.id+=s; m_curToken.id+=s;
p++; p++;
} }
if (m_curToken.id=="True") // treat true literal as numerical 1
{
m_curToken.type = ExprToken::Number;
m_curToken.num = 1;
}
else if (m_curToken.id=="False") // treat false literal as numerical 0
{
m_curToken.type = ExprToken::Number;
m_curToken.num = 0;
}
} }
else if (c=='"' || c=='\'') else if (c=='"' || c=='\'')
{ {
...@@ -2066,7 +2103,7 @@ class TemplateNodeBlock : public TemplateNodeCreator<TemplateNodeBlock> ...@@ -2066,7 +2103,7 @@ class TemplateNodeBlock : public TemplateNodeCreator<TemplateNodeBlock>
} }
// add 'block.super' variable to allow access to parent block content // add 'block.super' variable to allow access to parent block content
TemplateStruct superBlock; TemplateStruct superBlock;
superBlock.set("super",super.data()); superBlock.set("super",TemplateVariant(super.data(),TRUE));
ci->set("block",&superBlock); ci->set("block",&superBlock);
// render the overruled block contents // render the overruled block contents
nb->m_nodes.render(ts,c); nb->m_nodes.render(ts,c);
...@@ -2495,6 +2532,121 @@ class TemplateNodeWith : public TemplateNodeCreator<TemplateNodeWith> ...@@ -2495,6 +2532,121 @@ class TemplateNodeWith : public TemplateNodeCreator<TemplateNodeWith>
//---------------------------------------------------------- //----------------------------------------------------------
/** @brief Class representing an 'set' tag in a template */
class TemplateNodeCycle : public TemplateNodeCreator<TemplateNodeCycle>
{
public:
TemplateNodeCycle(TemplateParser *parser,TemplateNode *parent,int line,const QCString &data)
: TemplateNodeCreator<TemplateNodeCycle>(parser,parent,line)
{
TRACE(("{TemplateNodeCycle(%s)\n",data.data()));
m_args.setAutoDelete(TRUE);
m_index=0;
ExpressionParser expParser(parser->templateName(),line);
QValueList<QCString> args = split(data," ");
QValueListIterator<QCString> it = args.begin();
while (it!=args.end())
{
ExprAst *expr = expParser.parsePrimary(*it);
if (expr)
{
m_args.append(expr);
}
++it;
}
if (m_args.count()<2)
{
warn(parser->templateName(),line,"expected at least two arguments for cycle command, got %d",m_args.count());
}
TRACE(("}TemplateNodeCycle(%s)\n",data.data()));
}
void render(FTextStream &ts, TemplateContext *c)
{
TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c);
if (m_index<m_args.count())
{
TemplateVariant v = m_args.at(m_index)->resolve(c);
if (v.type()==TemplateVariant::Function)
{
v = v.call(QValueList<TemplateVariant>());
}
if (ci->escapeIntf() && !v.raw())
{
ts << ci->escapeIntf()->escape(v.toString());
}
else
{
ts << v.toString();
}
}
if (++m_index==m_args.count()) // wrap around
{
m_index=0;
}
}
private:
uint m_index;
QList<ExprAst> m_args;
};
//----------------------------------------------------------
/** @brief Class representing an 'set' tag in a template */
class TemplateNodeSet : public TemplateNodeCreator<TemplateNodeSet>
{
struct Mapping
{
Mapping(const QCString &n,ExprAst *e) : name(n), value(e) {}
~Mapping() { delete value; }
QCString name;
ExprAst *value;
};
public:
TemplateNodeSet(TemplateParser *parser,TemplateNode *parent,int line,const QCString &data)
: TemplateNodeCreator<TemplateNodeSet>(parser,parent,line)
{
TRACE(("{TemplateNodeSet(%s)\n",data.data()));
m_args.setAutoDelete(TRUE);
ExpressionParser expParser(parser->templateName(),line);
QValueList<QCString> args = split(data," ");
QValueListIterator<QCString> it = args.begin();
while (it!=args.end())
{
QCString arg = *it;
int j=arg.find('=');
if (j>0)
{
ExprAst *expr = expParser.parsePrimary(arg.mid(j+1));
if (expr)
{
m_args.append(new Mapping(arg.left(j),expr));
}
}
else
{
warn(parser->templateName(),line,"invalid argument '%s' for with tag",arg.data());
}
++it;
}
TRACE(("}TemplateNodeSet(%s)\n",data.data()));
}
void render(FTextStream &, TemplateContext *c)
{
TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c);
QListIterator<Mapping> it(m_args);
Mapping *mapping;
for (it.toFirst();(mapping=it.current());++it)
{
TemplateVariant value = mapping->value->resolve(c);
ci->set(mapping->name,value);
}
}
private:
QList<Mapping> m_args;
};
//----------------------------------------------------------
/** @brief Class representing an 'spaceless' tag in a template */ /** @brief Class representing an 'spaceless' tag in a template */
class TemplateNodeSpaceless : public TemplateNodeCreator<TemplateNodeSpaceless> class TemplateNodeSpaceless : public TemplateNodeCreator<TemplateNodeSpaceless>
{ {
...@@ -2667,9 +2819,11 @@ class TemplateNodeFactory ...@@ -2667,9 +2819,11 @@ class TemplateNodeFactory
static TemplateNodeFactory::AutoRegister<TemplateNodeIf> autoRefIf("if"); static TemplateNodeFactory::AutoRegister<TemplateNodeIf> autoRefIf("if");
static TemplateNodeFactory::AutoRegister<TemplateNodeFor> autoRefFor("for"); static TemplateNodeFactory::AutoRegister<TemplateNodeFor> autoRefFor("for");
static TemplateNodeFactory::AutoRegister<TemplateNodeMsg> autoRefMsg("msg"); static TemplateNodeFactory::AutoRegister<TemplateNodeMsg> autoRefMsg("msg");
static TemplateNodeFactory::AutoRegister<TemplateNodeSet> autoRefSet("set");
static TemplateNodeFactory::AutoRegister<TemplateNodeTree> autoRefTree("recursetree"); static TemplateNodeFactory::AutoRegister<TemplateNodeTree> autoRefTree("recursetree");
static TemplateNodeFactory::AutoRegister<TemplateNodeWith> autoRefWith("with"); static TemplateNodeFactory::AutoRegister<TemplateNodeWith> autoRefWith("with");
static TemplateNodeFactory::AutoRegister<TemplateNodeBlock> autoRefBlock("block"); static TemplateNodeFactory::AutoRegister<TemplateNodeBlock> autoRefBlock("block");
static TemplateNodeFactory::AutoRegister<TemplateNodeCycle> autoRefCycle("cycle");
static TemplateNodeFactory::AutoRegister<TemplateNodeExtend> autoRefExtend("extend"); static TemplateNodeFactory::AutoRegister<TemplateNodeExtend> autoRefExtend("extend");
static TemplateNodeFactory::AutoRegister<TemplateNodeCreate> autoRefCreate("create"); static TemplateNodeFactory::AutoRegister<TemplateNodeCreate> autoRefCreate("create");
static TemplateNodeFactory::AutoRegister<TemplateNodeInclude> autoRefInclude("include"); static TemplateNodeFactory::AutoRegister<TemplateNodeInclude> autoRefInclude("include");
......
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