mirror of
https://github.com/nasa/trick.git
synced 2024-12-30 01:48:52 +00:00
Accounted for namespace scoping issues
This commit is contained in:
parent
04e1d4b790
commit
fa42e8be67
@ -649,7 +649,6 @@ sub process_class($$$$$) {
|
||||
# If the type is qualified, assume it's fully qualified and put the
|
||||
# %template directive in the global namespace.
|
||||
# See https://github.com/nasa/trick/issues/768
|
||||
my $qualified = $template_type_no_sp =~ /^\w+(::)\w+</ ;
|
||||
#print "*** template_type_no_sp = $template_type_no_sp ***\n" ;
|
||||
if ( ! exists $processed_templates{$template_type_no_sp} ) {
|
||||
|
||||
@ -658,16 +657,23 @@ sub process_class($$$$$) {
|
||||
my $trick_swig_template = "TRICK_SWIG_TEMPLATE_$identifier" ;
|
||||
|
||||
my $typedef = "\n#ifndef $trick_swig_template\n" ;
|
||||
$typedef .= "\%template($identifier) $template_full_type;\n" ;
|
||||
$typedef .= "#define $trick_swig_template\n" ;
|
||||
$typedef .= "\%template($identifier) $template_full_type;\n" ;
|
||||
$typedef .= "#endif\n" ;
|
||||
|
||||
if ($qualified) {
|
||||
$global_template_typedefs .= $typedef
|
||||
} else {
|
||||
$template_typedefs .= $typedef
|
||||
if ($curr_namespace ne "") {
|
||||
my $in_same_namespace = 1 ;
|
||||
if ($template_full_type =~ /^\w*(::)\w+</) {
|
||||
$in_same_namespace = 0 ;
|
||||
}
|
||||
if ($in_same_namespace eq 0) {
|
||||
$curr_namespace =~ /(.*)::/ ;
|
||||
$typedef = "\n}" . $typedef . "namespace " . $1 . " {" ;
|
||||
}
|
||||
}
|
||||
|
||||
$template_typedefs .= $typedef ;
|
||||
|
||||
$processed_templates{$template_type_no_sp} = 1 ;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,27 @@ PURPOSE:
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
template <class T>
|
||||
class TemplateNoNS {};
|
||||
|
||||
class ClassNoNS {
|
||||
public:
|
||||
TemplateNoNS<int> tnns;
|
||||
};
|
||||
|
||||
namespace a {
|
||||
|
||||
template <class T>
|
||||
class Bar {};
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Bar<int> bar;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace my_ns {
|
||||
|
||||
class BB {
|
||||
|
Loading…
Reference in New Issue
Block a user