Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
doxverilog
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
doxverilog
Commits
6dbf32d5
Commit
6dbf32d5
authored
Dec 05, 2013
by
Dimitri van Heesch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More template and context enhancements
parent
4d5ddf77
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
752 additions
and
111 deletions
+752
-111
context.cpp
src/context.cpp
+598
-51
context.h
src/context.h
+2
-0
definition.cpp
src/definition.cpp
+8
-3
definition.h
src/definition.h
+5
-4
htmlgen.h
src/htmlgen.h
+1
-1
memberdef.cpp
src/memberdef.cpp
+30
-21
memberdef.h
src/memberdef.h
+8
-0
template.cpp
src/template.cpp
+11
-13
template.h
src/template.h
+65
-17
util.cpp
src/util.cpp
+23
-0
util.h
src/util.h
+1
-1
No files found.
src/context.cpp
View file @
6dbf32d5
This diff is collapsed.
Click to expand it.
src/context.h
View file @
6dbf32d5
...
...
@@ -25,6 +25,7 @@ class GroupDef;
class
GroupList
;
struct
IncludeInfo
;
class
MemberList
;
class
MemberSDict
;
class
MemberDef
;
struct
Argument
;
class
ArgumentList
;
...
...
@@ -650,6 +651,7 @@ class MemberListContext : public TemplateListIntf
{
public
:
MemberListContext
(
const
MemberList
*
ml
);
MemberListContext
(
MemberSDict
*
ml
,
bool
doSort
);
~
MemberListContext
();
// TemplateListIntf
...
...
src/definition.cpp
View file @
6dbf32d5
...
...
@@ -1050,6 +1050,13 @@ void Definition::setBodyDef(FileDef *fd)
m_impl
->
body
->
fileDef
=
fd
;
}
bool
Definition
::
hasSources
()
const
{
return
m_impl
->
body
&&
m_impl
->
body
->
startLine
!=-
1
&&
m_impl
->
body
->
endLine
>=
m_impl
->
body
->
startLine
&&
m_impl
->
body
->
fileDef
;
}
/*! Write code of this definition into the documentation */
void
Definition
::
writeInlineCode
(
OutputList
&
ol
,
const
char
*
scopeName
)
{
...
...
@@ -1057,9 +1064,7 @@ void Definition::writeInlineCode(OutputList &ol,const char *scopeName)
ol
.
pushGeneratorState
();
//printf("Source Fragment %s: %d-%d bodyDef=%p\n",name().data(),
// m_startBodyLine,m_endBodyLine,m_bodyDef);
if
(
inlineSources
&&
m_impl
->
body
&&
m_impl
->
body
->
startLine
!=-
1
&&
m_impl
->
body
->
endLine
>=
m_impl
->
body
->
startLine
&&
m_impl
->
body
->
fileDef
)
if
(
inlineSources
&&
hasSources
())
{
QCString
codeFragment
;
int
actualStart
=
m_impl
->
body
->
startLine
,
actualEnd
=
m_impl
->
body
->
endLine
;
...
...
src/definition.h
View file @
6dbf32d5
...
...
@@ -137,18 +137,18 @@ class Definition : public DefinitionIntf
virtual
QCString
getSourceAnchor
()
const
;
/*! Returns the detailed description of this definition */
QCString
documentation
()
const
;
virtual
QCString
documentation
()
const
;
/*! Returns the line number at which the detailed documentation was found. */
int
docLine
()
const
;
/*! Returns the file in which the detailed documentation block was found.
/*! Returns the file in which the detailed documentation block was found.
* This can differ from getDefFileName().
*/
QCString
docFile
()
const
;
/*! Returns the brief description of this definition. This can include commands. */
QCString
briefDescription
(
bool
abbreviate
=
FALSE
)
const
;
virtual
QCString
briefDescription
(
bool
abbreviate
=
FALSE
)
const
;
/*! Returns a plain text version of the brief description suitable for use
* as a tool tip.
...
...
@@ -259,6 +259,7 @@ class Definition : public DefinitionIntf
MemberSDict
*
getReferencedByMembers
()
const
;
bool
hasSections
()
const
;
bool
hasSources
()
const
;
/** returns TRUE if this class has a brief description */
bool
hasBriefDescription
()
const
;
...
...
src/htmlgen.h
View file @
6dbf32d5
...
...
@@ -282,7 +282,7 @@ class HtmlGenerator : public OutputGenerator
//{ t << "<tr><td valign=\"top\"><em>"; }
{
t
<<
"<tr><td class=
\"
fieldname
\"
><em>"
;
}
void
endDescTableTitle
()
{
t
<<
"</em>&
nbsp
;</td>"
;
}
{
t
<<
"</em>&
#160
;</td>"
;
}
void
startDescTableData
()
//{ t << "<td>" << endl; }
{
t
<<
"<td class=
\"
fielddoc
\"
>"
<<
endl
;
}
...
...
src/memberdef.cpp
View file @
6dbf32d5
...
...
@@ -449,27 +449,6 @@ static void writeTemplatePrefix(OutputList &ol,ArgumentList *al)
ol
.
docify
(
"> "
);
}
QCString
extractDirection
(
QCString
&
docs
)
{
QRegExp
re
(
"
\\
[[^
\\
]]+
\\
]"
);
// [...]
int
l
=
0
;
if
(
re
.
match
(
docs
,
0
,
&
l
)
==
0
)
{
int
inPos
=
docs
.
find
(
"in"
,
1
,
FALSE
);
int
outPos
=
docs
.
find
(
"out"
,
1
,
FALSE
);
bool
input
=
inPos
!=-
1
&&
inPos
<
l
;
bool
output
=
outPos
!=-
1
&&
outPos
<
l
;
if
(
input
||
output
)
// in,out attributes
{
docs
=
docs
.
mid
(
l
);
// strip attributes
if
(
input
&&
output
)
return
"[in,out]"
;
else
if
(
input
)
return
"[in]"
;
else
if
(
output
)
return
"[out]"
;
}
}
return
QCString
();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
...
...
@@ -4985,3 +4964,33 @@ void combineDeclarationAndDefinition(MemberDef *mdec,MemberDef *mdef)
}
}
QCString
MemberDef
::
briefDescription
(
bool
abbr
)
const
{
if
(
m_impl
->
templateMaster
)
{
return
m_impl
->
templateMaster
->
briefDescription
(
abbr
);
}
else
{
return
Definition
::
briefDescription
(
abbr
);
}
}
QCString
MemberDef
::
documentation
()
const
{
if
(
m_impl
->
templateMaster
)
{
return
m_impl
->
templateMaster
->
documentation
();
}
else
{
return
Definition
::
documentation
();
}
}
const
ArgumentList
*
MemberDef
::
typeConstraints
()
const
{
return
m_impl
->
typeConstraints
;
}
src/memberdef.h
View file @
6dbf32d5
...
...
@@ -245,6 +245,14 @@ class MemberDef : public Definition
QCString
getDeclType
()
const
;
void
getLabels
(
QStrList
&
sl
,
Definition
*
container
)
const
;
const
ArgumentList
*
typeConstraints
()
const
;
// overrules
QCString
documentation
()
const
;
QCString
briefDescription
(
bool
abbr
=
FALSE
)
const
;
//-----------------------------------------------------------------------------------
// ---- setters -----
//-----------------------------------------------------------------------------------
...
...
src/template.cpp
View file @
6dbf32d5
...
...
@@ -104,8 +104,7 @@ class TemplateVariant::Private
bool
boolVal
;
const
TemplateStructIntf
*
strukt
;
const
TemplateListIntf
*
list
;
FuncType
func
;
const
void
*
obj
;
Delegate
delegate
;
bool
raw
;
};
...
...
@@ -158,12 +157,11 @@ TemplateVariant::TemplateVariant(const TemplateListIntf *l)
p
->
list
=
l
;
}
TemplateVariant
::
TemplateVariant
(
const
void
*
obj
,
FuncType
f
)
TemplateVariant
::
TemplateVariant
(
const
TemplateVariant
::
Delegate
&
delegate
)
{
p
=
new
Private
;
p
->
type
=
Function
;
p
->
func
=
f
;
p
->
obj
=
obj
;
p
->
delegate
=
delegate
;
}
TemplateVariant
::~
TemplateVariant
()
...
...
@@ -184,8 +182,7 @@ TemplateVariant::TemplateVariant(const TemplateVariant &v)
case
String
:
p
->
strVal
=
v
.
p
->
strVal
;
break
;
case
Struct
:
p
->
strukt
=
v
.
p
->
strukt
;
break
;
case
List
:
p
->
list
=
v
.
p
->
list
;
break
;
case
Function
:
p
->
func
=
v
.
p
->
func
;
p
->
obj
=
v
.
p
->
obj
;
break
;
case
Function
:
p
->
delegate
=
v
.
p
->
delegate
;
break
;
}
}
...
...
@@ -201,8 +198,7 @@ TemplateVariant &TemplateVariant::operator=(const TemplateVariant &v)
case
String
:
p
->
strVal
=
v
.
p
->
strVal
;
break
;
case
Struct
:
p
->
strukt
=
v
.
p
->
strukt
;
break
;
case
List
:
p
->
list
=
v
.
p
->
list
;
break
;
case
Function
:
p
->
func
=
v
.
p
->
func
;
p
->
obj
=
v
.
p
->
obj
;
break
;
case
Function
:
p
->
delegate
=
v
.
p
->
delegate
;
break
;
}
return
*
this
;
}
...
...
@@ -305,7 +301,7 @@ const TemplateListIntf *TemplateVariant::toList() const
TemplateVariant
TemplateVariant
::
call
(
const
QValueList
<
TemplateVariant
>
&
args
)
{
if
(
p
->
type
==
Function
)
return
p
->
func
(
p
->
obj
,
args
);
if
(
p
->
type
==
Function
)
return
p
->
delegate
(
args
);
return
TemplateVariant
();
}
...
...
@@ -766,14 +762,12 @@ 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
...
...
@@ -2045,10 +2039,13 @@ class TemplateNodeMsg : public TemplateNodeCreator<TemplateNodeMsg>
TemplateContextImpl
*
ci
=
dynamic_cast
<
TemplateContextImpl
*>
(
c
);
TemplateEscapeIntf
*
escIntf
=
ci
->
escapeIntf
();
ci
->
setEscapeIntf
(
0
);
// avoid escaping things we send to standard out
bool
enable
=
ci
->
spacelessEnabled
();
ci
->
enableSpaceless
(
FALSE
);
FTextStream
ts
(
stdout
);
m_nodes
.
render
(
ts
,
c
);
ts
<<
endl
;
ci
->
setEscapeIntf
(
escIntf
);
ci
->
enableSpaceless
(
enable
);
}
private
:
TemplateNodeList
m_nodes
;
...
...
@@ -2423,7 +2420,8 @@ class TemplateNodeTree : public TemplateNodeCreator<TemplateNodeTree>
if
(
list
&&
list
->
count
()
>
0
)
// non-empty list
{
TreeContext
childCtx
(
this
,
list
,
ctx
->
templateCtx
);
TemplateVariant
children
(
&
childCtx
,
renderChildrenStub
);
// TemplateVariant children(&childCtx,renderChildrenStub);
TemplateVariant
children
(
TemplateVariant
::
Delegate
::
fromFunction
(
&
childCtx
,
renderChildrenStub
));
children
.
setRaw
(
TRUE
);
c
->
set
(
"children"
,
children
);
m_treeNodes
.
render
(
ss
,
c
);
...
...
src/template.h
View file @
6dbf32d5
...
...
@@ -26,7 +26,7 @@ class TemplateEngine;
* When the template engine encounters a variable, it evaluates that variable and
* replaces it with the result. Variable names consist of any combination of
* alphanumeric characters and the underscore ("_").
* Use a dot (.) to access attributes of a variable.
* Use a dot (.) to access attributes of a
structured
variable.
*
* One can modify variables for display by using \b filters, for example:
* `{{ value|default:"nothing" }}`
...
...
@@ -40,28 +40,33 @@ class TemplateEngine;
*
* Supported Django tags:
* - `for ... empty ... endfor`
* - `if ... else ... endif`
* - `block ... endblock`
* - `if ... else ... endif`
* - `block ... endblock`
* - `extend`
* - `include`
* - `with ... endwith`
* - `spaceless ... endspaceless`
* - `cycle`
*
* Extension tags:
* - `create` which instantiates a template and writes the result to a file.
* The syntax is `{% create 'filename' from 'template' %}`.
* - `recursetree`
* - `markers`
* - `msg` ... `endmsg`
* - `set`
*
* Supported Django filters:
* - `default`
* - `length`
* - `add`
*
* Extension tags:
* - `create` which instantiates a template and writes the result to a file.
* The syntax is `{% create 'filename' from 'template' %}`.
* - `recursetree`
* - `markers`
* - `divisibleby`
*
* Extension filters:
* - `stripPath`
* - `nowrap`
* - `prepend`
* - `append`
*
* @{
*/
...
...
@@ -70,8 +75,50 @@ class TemplateEngine;
class
TemplateVariant
{
public
:
/** Signature of the callback function, used for function type variants */
typedef
TemplateVariant
(
*
FuncType
)(
const
void
*
obj
,
const
QValueList
<
TemplateVariant
>
&
args
);
/** @brief Helper class to create a delegate that can store a function/method call. */
class
Delegate
{
public
:
/** Callback type to use when creating a delegate from a function. */
typedef
TemplateVariant
(
*
StubType
)(
const
void
*
obj
,
const
QValueList
<
TemplateVariant
>
&
args
);
Delegate
()
:
m_objectPtr
(
0
)
,
m_stubPtr
(
0
)
{}
/** Creates a delegate given an object. The method to call is passed as a template parameter */
template
<
class
T
,
TemplateVariant
(
T
::*
TMethod
)(
const
QValueList
<
TemplateVariant
>
&
)
const
>
static
Delegate
fromMethod
(
const
T
*
objectPtr
)
{
Delegate
d
;
d
.
m_objectPtr
=
objectPtr
;
d
.
m_stubPtr
=
&
methodStub
<
T
,
TMethod
>
;
return
d
;
}
/** Creates a delegate given an object, and a plain function. */
static
Delegate
fromFunction
(
const
void
*
obj
,
StubType
func
)
{
Delegate
d
;
d
.
m_objectPtr
=
obj
;
d
.
m_stubPtr
=
func
;
return
d
;
}
/** Invokes the function/method stored in the delegate */
TemplateVariant
operator
()(
const
QValueList
<
TemplateVariant
>
&
args
)
const
{
return
(
*
m_stubPtr
)(
m_objectPtr
,
args
);
}
private
:
const
void
*
m_objectPtr
;
StubType
m_stubPtr
;
template
<
class
T
,
TemplateVariant
(
T
::*
TMethod
)(
const
QValueList
<
TemplateVariant
>
&
)
const
>
static
TemplateVariant
methodStub
(
const
void
*
objectPtr
,
const
QValueList
<
TemplateVariant
>
&
args
)
{
T
*
p
=
(
T
*
)(
objectPtr
);
return
(
p
->*
TMethod
)(
args
);
}
};
/** Types of data that can be stored in a TemplateVariant */
enum
Type
{
None
,
Bool
,
Integer
,
String
,
Struct
,
List
,
Function
};
...
...
@@ -109,13 +156,14 @@ class TemplateVariant
*/
TemplateVariant
(
const
TemplateListIntf
*
l
);
/** Constructs a new variant which represents a function
* @param[in] obj Opaque user defined pointer, which
* is passed back when call() is invoked.
* @param[in] func Callback function to invoke when
/** Constructs a new variant which represents a method call
* @param[in] delegate Delegate object to invoke when
* calling call() on this variant.
* @note Use TemplateVariant::Delegate::fromMethod() and
* TemplateVariant::Delegate::fromFunction() to create
* Delegate objects.
*/
TemplateVariant
(
const
void
*
obj
,
FuncType
func
);
TemplateVariant
(
const
Delegate
&
delegate
);
/** Destroys the Variant object */
~
TemplateVariant
();
...
...
@@ -167,7 +215,7 @@ class TemplateVariant
* @see setRaw()
*/
bool
raw
()
const
;
private
:
class
Private
;
Private
*
p
;
...
...
src/util.cpp
View file @
6dbf32d5
...
...
@@ -8057,3 +8057,26 @@ bool classVisibleInIndex(ClassDef *cd)
return
(
allExternals
&&
cd
->
isLinkable
())
||
cd
->
isLinkableInProject
();
}
//----------------------------------------------------------------------------
QCString
extractDirection
(
QCString
&
docs
)
{
QRegExp
re
(
"
\\
[[^
\\
]]+
\\
]"
);
// [...]
int
l
=
0
;
if
(
re
.
match
(
docs
,
0
,
&
l
)
==
0
)
{
int
inPos
=
docs
.
find
(
"in"
,
1
,
FALSE
);
int
outPos
=
docs
.
find
(
"out"
,
1
,
FALSE
);
bool
input
=
inPos
!=-
1
&&
inPos
<
l
;
bool
output
=
outPos
!=-
1
&&
outPos
<
l
;
if
(
input
||
output
)
// in,out attributes
{
docs
=
docs
.
mid
(
l
);
// strip attributes
if
(
input
&&
output
)
return
"[in,out]"
;
else
if
(
input
)
return
"[in]"
;
else
if
(
output
)
return
"[out]"
;
}
}
return
QCString
();
}
src/util.h
View file @
6dbf32d5
...
...
@@ -446,7 +446,7 @@ uint getUtf8Code( const QCString& s, int idx );
uint
getUtf8CodeToLower
(
const
QCString
&
s
,
int
idx
);
uint
getUtf8CodeToUpper
(
const
QCString
&
s
,
int
idx
);
QCString
extractDirection
(
QCString
&
docs
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment