Skip to content

Commit

Permalink
Added swig support for templates with array parameters (#1742)
Browse files Browse the repository at this point in the history
* Added support for templates with array parameters

* Added test case for array templates
  • Loading branch information
Pherring04 authored Jul 16, 2024
1 parent f2e93ac commit 7b4253d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libexec/trick/convert_swig
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ my $template_def = qr/template\s* # keyword template
\s+[_A-Za-z]\w*\s* # class name
/sx ;
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 ;
/sx ;

Expand Down
17 changes: 17 additions & 0 deletions test/SIM_test_ip/S_define
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,25 @@ LIBRARY DEPENDENCIES:
#include "sim_objects/default_trick_sys.sm"

##include "test_ip/include/ClassOfEverything.hh"
##include "test_ip/include/ArrayTemplate.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 {

public:
Expand Down
37 changes: 37 additions & 0 deletions test/SIM_test_ip/models/test_ip/include/ArrayTemplate.hh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7b4253d

Please sign in to comment.