Added swig support for templates with array parameters (#1742)

* Added support for templates with array parameters

* Added test case for array templates
This commit is contained in:
Pherring04 2024-07-16 10:44:04 -05:00 committed by GitHub
parent f2e93ac490
commit 7b4253d703
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 55 additions and 1 deletions

View File

@ -97,7 +97,7 @@ my $template_def = qr/template\s* # keyword template
\s+[_A-Za-z]\w*\s* # class name \s+[_A-Za-z]\w*\s* # class name
/sx ; /sx ;
my $template_var_def = qr/(?:\:\:)?[_A-Za-z][:\w]*\s* # template name my $template_var_def = qr/(?:\:\:)?[_A-Za-z][:\w]*\s* # template name
<[\w\s\*,:<>]*>\s* # template parameters <[\w\s\*,:<>\[\]]*>\s* # template parameters
[_A-Za-z]\w*\s*(?:[{=].*?)?; # var name ; [_A-Za-z]\w*\s*(?:[{=].*?)?; # var name ;
/sx ; /sx ;

View File

@ -9,8 +9,25 @@ LIBRARY DEPENDENCIES:
#include "sim_objects/default_trick_sys.sm" #include "sim_objects/default_trick_sys.sm"
##include "test_ip/include/ClassOfEverything.hh" ##include "test_ip/include/ClassOfEverything.hh"
##include "test_ip/include/ArrayTemplate.hh"
##include "test_ip/include/OverloadedVariable.hh" ##include "test_ip/include/OverloadedVariable.hh"
class ArrayTemplateSimObject : public Trick::SimObject
{
public:
ArrayTemplateSimObject(const ArrayTemplateSimObject&) = delete;
ArrayTemplateSimObject& operator=(const ArrayTemplateSimObject&) = delete;
double a[3];
ArrayTemplate<double[3]> arryTemp;
ArrayTemplateSimObject()
: arryTemp(a)
{
}
};
ArrayTemplateSimObject arry_temp_object;
class testSimObject : public Trick::SimObject { class testSimObject : public Trick::SimObject {
public: public:

View File

@ -0,0 +1,37 @@
/**
@file
@verbatim
PURPOSE:
(Test if we can build with arrays as template parameters)
@endverbatim
*******************************************************************************/
#ifndef ARRAY_TEMPLATE_TESTS_HH
#define ARRAY_TEMPLATE_TESTS_HH
// System include files.
#include <string>
#include <iostream>
#include <sstream>
template <class SourceType>
class ArrayTemplate
{
public:
ArrayTemplate(const SourceType& source)
: source(source)
{
}
ArrayTemplate(const ArrayTemplate&) = delete;
ArrayTemplate& operator=(const ArrayTemplate&) = delete;
private:
const SourceType& source;
};
#endif