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
47bc520a
Commit
47bc520a
authored
May 10, 2014
by
Dimitri van Heesch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed append filter and added index and path attributes to node
parent
edd05630
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
2 deletions
+57
-2
template.cpp
src/template.cpp
+57
-2
No files found.
src/template.cpp
View file @
47bc520a
...
@@ -738,13 +738,34 @@ class FilterAdd
...
@@ -738,13 +738,34 @@ class FilterAdd
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
/** @brief The implementation of the "append" filter */
class
FilterAppend
{
public
:
static
TemplateVariant
apply
(
const
TemplateVariant
&
v
,
const
TemplateVariant
&
arg
)
{
if
((
v
.
type
()
==
TemplateVariant
::
String
||
v
.
type
()
==
TemplateVariant
::
Integer
)
&&
arg
.
type
()
==
TemplateVariant
::
String
)
{
return
TemplateVariant
(
v
.
toString
()
+
arg
.
toString
());
}
else
{
return
v
;
}
}
};
//-----------------------------------------------------------------------------
/** @brief The implementation of the "prepend" filter */
/** @brief The implementation of the "prepend" filter */
class
FilterPrepend
class
FilterPrepend
{
{
public
:
public
:
static
TemplateVariant
apply
(
const
TemplateVariant
&
v
,
const
TemplateVariant
&
arg
)
static
TemplateVariant
apply
(
const
TemplateVariant
&
v
,
const
TemplateVariant
&
arg
)
{
{
if
(
v
.
type
()
==
TemplateVariant
::
String
&&
arg
.
type
()
==
TemplateVariant
::
String
)
if
((
v
.
type
()
==
TemplateVariant
::
String
||
v
.
type
()
==
TemplateVariant
::
Integer
)
&&
arg
.
type
()
==
TemplateVariant
::
String
)
{
{
return
TemplateVariant
(
arg
.
toString
()
+
v
.
toString
());
return
TemplateVariant
(
arg
.
toString
()
+
v
.
toString
());
}
}
...
@@ -1102,7 +1123,7 @@ class TemplateFilterFactory
...
@@ -1102,7 +1123,7 @@ 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
<
FilterA
dd
>
fAppend
(
"append"
);
static
TemplateFilterFactory
::
AutoRegister
<
FilterA
ppend
>
fAppend
(
"append"
);
static
TemplateFilterFactory
::
AutoRegister
<
FilterLength
>
fLength
(
"length"
);
static
TemplateFilterFactory
::
AutoRegister
<
FilterLength
>
fLength
(
"length"
);
static
TemplateFilterFactory
::
AutoRegister
<
FilterNoWrap
>
fNoWrap
(
"nowrap"
);
static
TemplateFilterFactory
::
AutoRegister
<
FilterNoWrap
>
fNoWrap
(
"nowrap"
);
static
TemplateFilterFactory
::
AutoRegister
<
FilterFlatten
>
fFlatten
(
"flatten"
);
static
TemplateFilterFactory
::
AutoRegister
<
FilterFlatten
>
fFlatten
(
"flatten"
);
...
@@ -2214,6 +2235,24 @@ void TemplateContextImpl::closeSubIndex(const QCString &indexName)
...
@@ -2214,6 +2235,24 @@ void TemplateContextImpl::closeSubIndex(const QCString &indexName)
}
}
}
}
static
void
getPathListFunc
(
TemplateStructIntf
*
entry
,
TemplateList
*
list
)
{
TemplateVariant
parent
=
entry
->
get
(
"parent"
);
if
(
parent
.
type
()
==
TemplateVariant
::
Struct
)
{
getPathListFunc
(
parent
.
toStruct
(),
list
);
}
list
->
append
(
entry
);
}
static
TemplateVariant
getPathFunc
(
const
void
*
ctx
,
const
QValueList
<
TemplateVariant
>
&
)
{
TemplateStruct
*
entry
=
(
TemplateStruct
*
)
ctx
;
TemplateList
*
result
=
TemplateList
::
alloc
();
getPathListFunc
(
entry
,
result
);
return
result
;
}
void
TemplateContextImpl
::
addIndexEntry
(
const
QCString
&
indexName
,
const
QValueList
<
TemplateKeyValue
>
&
arguments
)
void
TemplateContextImpl
::
addIndexEntry
(
const
QCString
&
indexName
,
const
QValueList
<
TemplateKeyValue
>
&
arguments
)
{
{
QValueListConstIterator
<
TemplateKeyValue
>
it
=
arguments
.
begin
();
QValueListConstIterator
<
TemplateKeyValue
>
it
=
arguments
.
begin
();
...
@@ -2223,6 +2262,7 @@ void TemplateContextImpl::addIndexEntry(const QCString &indexName,const QValueLi
...
@@ -2223,6 +2262,7 @@ void TemplateContextImpl::addIndexEntry(const QCString &indexName,const QValueLi
// printf(" key=%s value=%s\n",(*it).key.data(),(*it).value.toString().data());
// printf(" key=%s value=%s\n",(*it).key.data(),(*it).value.toString().data());
// ++it;
// ++it;
//}
//}
TemplateVariant
parent
(
FALSE
);
QStack
<
TemplateVariant
>
*
stack
=
m_indexStacks
.
find
(
indexName
);
QStack
<
TemplateVariant
>
*
stack
=
m_indexStacks
.
find
(
indexName
);
if
(
!
stack
)
// no stack yet, create it!
if
(
!
stack
)
// no stack yet, create it!
{
{
...
@@ -2248,6 +2288,13 @@ void TemplateContextImpl::addIndexEntry(const QCString &indexName,const QValueLi
...
@@ -2248,6 +2288,13 @@ void TemplateContextImpl::addIndexEntry(const QCString &indexName,const QValueLi
{
{
ASSERT
(
stack
->
top
()
->
type
()
==
TemplateVariant
::
List
);
ASSERT
(
stack
->
top
()
->
type
()
==
TemplateVariant
::
List
);
}
}
if
(
stack
->
count
()
>
1
)
{
TemplateVariant
*
tmp
=
stack
->
pop
();
parent
=
*
stack
->
top
();
stack
->
push
(
tmp
);
ASSERT
(
parent
.
type
()
==
TemplateVariant
::
Struct
);
}
// get list to add new item
// get list to add new item
list
=
dynamic_cast
<
TemplateList
*>
(
stack
->
top
()
->
toList
());
list
=
dynamic_cast
<
TemplateList
*>
(
stack
->
top
()
->
toList
());
}
}
...
@@ -2264,6 +2311,9 @@ void TemplateContextImpl::addIndexEntry(const QCString &indexName,const QValueLi
...
@@ -2264,6 +2311,9 @@ void TemplateContextImpl::addIndexEntry(const QCString &indexName,const QValueLi
}
}
entry
->
set
(
"is_leaf_node"
,
true
);
entry
->
set
(
"is_leaf_node"
,
true
);
entry
->
set
(
"first"
,
list
->
count
()
==
0
);
entry
->
set
(
"first"
,
list
->
count
()
==
0
);
entry
->
set
(
"index"
,
list
->
count
());
entry
->
set
(
"parent"
,
parent
);
entry
->
set
(
"path"
,
TemplateVariant
::
Delegate
::
fromFunction
(
entry
,
getPathFunc
));
entry
->
set
(
"last"
,
true
);
entry
->
set
(
"last"
,
true
);
stack
->
push
(
new
TemplateVariant
(
entry
));
stack
->
push
(
new
TemplateVariant
(
entry
));
list
->
append
(
entry
);
list
->
append
(
entry
);
...
@@ -2785,6 +2835,10 @@ class TemplateNodeFor : public TemplateNodeCreator<TemplateNodeFor>
...
@@ -2785,6 +2835,10 @@ class TemplateNodeFor : public TemplateNodeCreator<TemplateNodeFor>
if
(
m_expr
)
if
(
m_expr
)
{
{
TemplateVariant
v
=
m_expr
->
resolve
(
c
);
TemplateVariant
v
=
m_expr
->
resolve
(
c
);
if
(
v
.
type
()
==
TemplateVariant
::
Function
)
{
v
=
v
.
call
(
QValueList
<
TemplateVariant
>
());
}
const
TemplateListIntf
*
list
=
v
.
toList
();
const
TemplateListIntf
*
list
=
v
.
toList
();
if
(
list
)
if
(
list
)
{
{
...
@@ -3160,6 +3214,7 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate>
...
@@ -3160,6 +3214,7 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate>
{
{
QCString
templateFile
=
m_templateExpr
->
resolve
(
c
).
toString
();
QCString
templateFile
=
m_templateExpr
->
resolve
(
c
).
toString
();
QCString
outputFile
=
m_fileExpr
->
resolve
(
c
).
toString
();
QCString
outputFile
=
m_fileExpr
->
resolve
(
c
).
toString
();
printf
(
"TemplateNodeCreate file='%s' template='%s'
\n
"
,
outputFile
.
data
(),
templateFile
.
data
());
if
(
templateFile
.
isEmpty
())
if
(
templateFile
.
isEmpty
())
{
{
ci
->
warn
(
m_templateName
,
m_line
,
"empty template name parameter for create command
\n
"
);
ci
->
warn
(
m_templateName
,
m_line
,
"empty template name parameter for create command
\n
"
);
...
...
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