Commit 47014319 authored by wtschueller's avatar wtschueller

Tcl: correct namespace resolution in case of INLINE_SOURCES = YES

parent 06bd53ac
......@@ -534,6 +534,24 @@ static void tcl_name(const QCString &ns0, const QCString &name0, QCString &ns, Q
}
}
//! Check name. Strip namespace qualifiers from name0 if inside inlined code segment.
// @return 'ns' and 'name' of given current 'ns0' and 'name0'
static void tcl_name_SnippetAware(const QCString &ns0, const QCString &name0, QCString &ns, QCString &name)
{
// If we are inside an inlined code snippet then ns0
// already containes the complete namespace path.
// Any namespace qualifiers in name0 are redundant.
int i = name0.findRev("::");
if (i>=0 && tcl.memberdef)
{
tcl_name(ns0, name0.mid(i+2), ns, name);
}
else
{
tcl_name(ns0, name0, ns, name);
}
}
// Check and return namespace entry.
// @return namespace entry
Entry* tcl_entry_namespace(const QCString ns)
......@@ -2099,7 +2117,7 @@ D
tcl_codify_cmd(NULL,3);
tcl_codify_cmd(NULL,4);
tcl_codify_cmd(NULL,5);
tcl_name(myScan->ns,(*tcl.list_commandwords.at(2)).utf8(),myNs,myName);
tcl_name_SnippetAware(myScan->ns,(*tcl.list_commandwords.at(2)).utf8(),myNs,myName);
if (myNs.length())
{
myEntryNs = tcl_entry_namespace(myNs);
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="">
<compounddef id="namespacen1" kind="namespace">
<compoundname>n1</compoundname>
<innernamespace refid="namespacen1_1_1n1">n1::n1</innernamespace>
<sectiondef kind="func">
<memberdef kind="function" id="namespacen1_1a9f23d7a7f141915457e8e26023d70cb4" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type/>
<definition>n1::p1</definition>
<argsstring>args</argsstring>
<name>p1</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="062_namespace_resolution.tcl" bodystart="12" bodyend="16"/>
<references refid="namespacen1_1a0bff29f718fa43e49b7ca79985afb5fa" compoundref="062__namespace__resolution_8tcl" startline="17" endline="20">p2</references>
</memberdef>
<memberdef kind="function" id="namespacen1_1a0bff29f718fa43e49b7ca79985afb5fa" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type/>
<definition>n1::p2</definition>
<argsstring>args</argsstring>
<name>p2</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="062_namespace_resolution.tcl" bodystart="17" bodyend="20"/>
<referencedby refid="namespacen1_1a9f23d7a7f141915457e8e26023d70cb4" compoundref="062__namespace__resolution_8tcl" startline="12" endline="16">p1</referencedby>
</memberdef>
</sectiondef>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<location file="062_namespace_resolution.tcl" line="11" column="1"/>
</compounddef>
</doxygen>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="">
<compounddef id="namespacen2" kind="namespace">
<compoundname>n2</compoundname>
<innernamespace refid="namespacen2_1_1n2">n2::n2</innernamespace>
<sectiondef kind="func">
<memberdef kind="function" id="namespacen2_1a74950c0185232e374220a0707b4903c6" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type/>
<definition>n2::p1</definition>
<argsstring>args</argsstring>
<name>p1</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="062_namespace_resolution.tcl" bodystart="31" bodyend="35"/>
<references refid="namespacen2_1a49fadfbefa795204a3c566ec76ff632f" compoundref="062__namespace__resolution_8tcl" startline="36" endline="39">p2</references>
</memberdef>
<memberdef kind="function" id="namespacen2_1a49fadfbefa795204a3c566ec76ff632f" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type/>
<definition>n2::p2</definition>
<argsstring>args</argsstring>
<name>p2</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="062_namespace_resolution.tcl" bodystart="36" bodyend="39"/>
<referencedby refid="namespacen2_1a74950c0185232e374220a0707b4903c6" compoundref="062__namespace__resolution_8tcl" startline="31" endline="35">p1</referencedby>
</memberdef>
</sectiondef>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<location file="062_namespace_resolution.tcl" line="29" column="1"/>
</compounddef>
</doxygen>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="">
<compounddef id="namespacen3" kind="namespace">
<compoundname>n3</compoundname>
<innernamespace refid="namespacen3_1_1n3">n3::n3</innernamespace>
<sectiondef kind="func">
<memberdef kind="function" id="namespacen3_1ae7e87e49507bd56dad087cffecd35b29" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type/>
<definition>n3::p1</definition>
<argsstring>args</argsstring>
<name>p1</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="062_namespace_resolution.tcl" bodystart="47" bodyend="51"/>
<references refid="namespacen3_1a14e9fe1b27a6d36db9ace2eef4509979" compoundref="062__namespace__resolution_8tcl" startline="52" endline="55">p2</references>
</memberdef>
<memberdef kind="function" id="namespacen3_1a14e9fe1b27a6d36db9ace2eef4509979" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type/>
<definition>n3::p2</definition>
<argsstring>args</argsstring>
<name>p2</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="062_namespace_resolution.tcl" bodystart="52" bodyend="55"/>
<referencedby refid="namespacen3_1ae7e87e49507bd56dad087cffecd35b29" compoundref="062__namespace__resolution_8tcl" startline="47" endline="51">p1</referencedby>
</memberdef>
</sectiondef>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<location file="062_namespace_resolution.tcl" line="45" column="1"/>
</compounddef>
</doxygen>
#// objective: tests correct namespace resolution, only references/referencedby relations are relevant
#// check: namespacen1.xml
#// check: namespacen2.xml
#// check: namespacen3.xml
#// config: REFERENCED_BY_RELATION = yes
#// config: REFERENCES_RELATION = yes
#// config: EXTRACT_ALL = yes
#// config: INLINE_SOURCES = yes
# now: combine namespace eval and qualified names
namespace eval n1 {
proc p1 args {
array set info [info frame 0]; puts -nonewline ->$info(proc)
p2
return
}
proc p2 args {
array set info [info frame 0]; puts -nonewline ->$info(proc)
return
}
namespace eval n1 {
proc p1 args {
array set info [info frame 0]; puts -nonewline ->$info(proc)
return
}
}
}
# same thing, but fully qualified proc names
namespace eval ::n2 {}
namespace eval ::n2::n2 {}
proc ::n2::p1 args {
array set info [info frame 0]; puts -nonewline ->$info(proc)
p2
return
}
proc ::n2::p2 args {
array set info [info frame 0]; puts -nonewline ->$info(proc)
return
}
proc ::n2::n2::p2 args {
array set info [info frame 0]; puts -nonewline ->$info(proc)
return
}
# same thing, without leading ::
namespace eval n3 {}
namespace eval n3::n3 {}
proc n3::p1 args {
array set info [info frame 0]; puts -nonewline ->$info(proc)
p2
return
}
proc n3::p2 args {
array set info [info frame 0]; puts -nonewline ->$info(proc)
return
}
proc n3::n3::p2 args {
array set info [info frame 0]; puts -nonewline ->$info(proc)
return
}
# now, check with tcl what is called
n1::p1
puts ""
n2::p1
puts ""
n3::p1
puts ""
exit
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