mirror of
https://github.com/nasa/trick.git
synced 2024-12-19 05:07:54 +00:00
New STL framework doesn't support const #293
So using consts as arguments to STLs causes errors in our io code and SWIG. Added a check for const template arguments and going to ignore them for both ICG and what we input to SWIG.
This commit is contained in:
parent
0072e7d6f0
commit
858602fe01
@ -629,30 +629,33 @@ sub process_class($$$$$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( $template_var_def_str ne "" ) {
|
if ( $template_var_def_str ne "" ) {
|
||||||
#print "*** template_var = $template_var_def_str ***\n" ;
|
# if there is a whiff of const in the template we are punting.
|
||||||
$template_var_def_str =~ /(.*?)([_A-Za-z]\w*)\s*;/s ;
|
if ( $template_var_def_str !~ /^const|[<,\s]const\s/ ) {
|
||||||
my ($template_full_type) = $1 ;
|
#print "*** template_var = $template_var_def_str ***\n" ;
|
||||||
my ($var_name) = $2 ;
|
$template_var_def_str =~ /(.*?)([_A-Za-z]\w*)\s*;/s ;
|
||||||
#print "*** var_name = $var_name ***\n" ;
|
my ($template_full_type) = $1 ;
|
||||||
$$new_contents_ref .= $template_var_def_str ;
|
my ($var_name) = $2 ;
|
||||||
|
#print "*** var_name = $var_name ***\n" ;
|
||||||
|
$$new_contents_ref .= $template_var_def_str ;
|
||||||
|
|
||||||
$template_full_type =~ /([_A-Za-z][:\w]*)\s*</ ;
|
$template_full_type =~ /([_A-Za-z][:\w]*)\s*</ ;
|
||||||
my ($template_type) = $1 ;
|
my ($template_type) = $1 ;
|
||||||
# ignore some STL types and types that involve std::wstring
|
# ignore some STL types and types that involve std::wstring
|
||||||
if ( (( $stls and ! exists $stl_names{$template_type})
|
if ( (( $stls and ! exists $stl_names{$template_type})
|
||||||
or ( !$stls and ! exists $all_stl_names{$template_type} ))
|
or ( !$stls and ! exists $all_stl_names{$template_type} ))
|
||||||
and $template_full_type !~ /(std::)?wstring/ ) {
|
and $template_full_type !~ /(std::)?wstring/ ) {
|
||||||
|
|
||||||
my ($template_type_no_sp) = $template_full_type ;
|
my ($template_type_no_sp) = $template_full_type ;
|
||||||
$template_type_no_sp =~ s/\s//g ;
|
$template_type_no_sp =~ s/\s//g ;
|
||||||
#print "*** template_type_no_sp = $template_type_no_sp ***\n" ;
|
#print "*** template_type_no_sp = $template_type_no_sp ***\n" ;
|
||||||
if ( ! exists $processed_templates{$template_type_no_sp} ) {
|
if ( ! exists $processed_templates{$template_type_no_sp} ) {
|
||||||
$$new_contents_ref .= "\n#define TRICK_SWIG_TEMPLATE_$class_name${var_name}_template\n" ;
|
$$new_contents_ref .= "\n#define TRICK_SWIG_TEMPLATE_$class_name${var_name}_template\n" ;
|
||||||
$template_typedefs .= "\n#ifdef TRICK_SWIG_TEMPLATE_$class_name${var_name}_template\n" ;
|
$template_typedefs .= "\n#ifdef TRICK_SWIG_TEMPLATE_$class_name${var_name}_template\n" ;
|
||||||
$template_typedefs .= "\%template ($class_name${var_name}_template) $template_full_type ;\n" ;
|
$template_typedefs .= "\%template ($class_name${var_name}_template) $template_full_type ;\n" ;
|
||||||
$template_typedefs .= "#undef TRICK_SWIG_TEMPLATE_$class_name${var_name}_template\n" ;
|
$template_typedefs .= "#undef TRICK_SWIG_TEMPLATE_$class_name${var_name}_template\n" ;
|
||||||
$template_typedefs .= "#endif\n" ;
|
$template_typedefs .= "#endif\n" ;
|
||||||
$processed_templates{$template_type_no_sp} = 1 ;
|
$processed_templates{$template_type_no_sp} = 1 ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,6 +372,35 @@ static bool checkForPrivateTemplateArgs( clang::ClassTemplateSpecializationDecl
|
|||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool checkForConstTemplateArgs( clang::ClassTemplateSpecializationDecl * ctsd ) {
|
||||||
|
unsigned int ii ;
|
||||||
|
for ( ii = 0 ; ii < ctsd->getTemplateArgs().size() ; ii++ ) {
|
||||||
|
const clang::TemplateArgument & ta = ctsd->getTemplateArgs().get(ii) ;
|
||||||
|
if ( ta.getKind() == clang::TemplateArgument::Type ) {
|
||||||
|
clang::QualType qt = ta.getAsType() ;
|
||||||
|
//std::cout << qt.getAsString() << std::endl ;
|
||||||
|
if ( qt.isConstQualified() ) {
|
||||||
|
//std::cout << " is const qualified" << std::endl ;
|
||||||
|
return true ;
|
||||||
|
} else {
|
||||||
|
//std::cout << " is public embedded class" << std::endl ;
|
||||||
|
const clang::Type * t = qt.getTypePtrOrNull() ;
|
||||||
|
if ( t != NULL ) {
|
||||||
|
if (t->getTypeClass() == clang::Type::Record ) {
|
||||||
|
clang::CXXRecordDecl * crd = t->getAsCXXRecordDecl() ;
|
||||||
|
if ( clang::isa<clang::ClassTemplateSpecializationDecl>(crd) ) {
|
||||||
|
clang::ClassTemplateSpecializationDecl * inner_ctsd ;
|
||||||
|
inner_ctsd = clang::cast<clang::ClassTemplateSpecializationDecl>(crd) ;
|
||||||
|
return checkForConstTemplateArgs(inner_ctsd) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
static std::map<std::string, bool> stl_classes = init_stl_classes() ;
|
static std::map<std::string, bool> stl_classes = init_stl_classes() ;
|
||||||
|
|
||||||
bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
|
bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
|
||||||
@ -430,6 +459,12 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
|
|||||||
fdes->setIO(0) ;
|
fdes->setIO(0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the template is using a const type the STL checkpoint code will not compile,
|
||||||
|
// we need to ignore the variable.
|
||||||
|
if ( checkForConstTemplateArgs( ctsd )) {
|
||||||
|
fdes->setIO(0) ;
|
||||||
|
}
|
||||||
|
|
||||||
fdes->setEnumString("TRICK_STL") ;
|
fdes->setEnumString("TRICK_STL") ;
|
||||||
fdes->setSTL(true) ;
|
fdes->setSTL(true) ;
|
||||||
fdes->setTypeName(tst_string) ;
|
fdes->setTypeName(tst_string) ;
|
||||||
|
Loading…
Reference in New Issue
Block a user