From 7b4253d7035b695af2ff4f6477038c4bf70f652e Mon Sep 17 00:00:00 2001 From: Pherring04 <158035107+Pherring04@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:44:04 -0500 Subject: [PATCH] Added swig support for templates with array parameters (#1742) * Added support for templates with array parameters * Added test case for array templates --- libexec/trick/convert_swig | 2 +- test/SIM_test_ip/S_define | 17 +++++++++ .../models/test_ip/include/ArrayTemplate.hh | 37 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 test/SIM_test_ip/models/test_ip/include/ArrayTemplate.hh diff --git a/libexec/trick/convert_swig b/libexec/trick/convert_swig index 92980ad3..6ed0be49 100755 --- a/libexec/trick/convert_swig +++ b/libexec/trick/convert_swig @@ -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 ; diff --git a/test/SIM_test_ip/S_define b/test/SIM_test_ip/S_define index eef7b547..62cec0ab 100644 --- a/test/SIM_test_ip/S_define +++ b/test/SIM_test_ip/S_define @@ -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 arryTemp; + + ArrayTemplateSimObject() + : arryTemp(a) + { + } +}; +ArrayTemplateSimObject arry_temp_object; + class testSimObject : public Trick::SimObject { public: diff --git a/test/SIM_test_ip/models/test_ip/include/ArrayTemplate.hh b/test/SIM_test_ip/models/test_ip/include/ArrayTemplate.hh new file mode 100644 index 00000000..b65c91c7 --- /dev/null +++ b/test/SIM_test_ip/models/test_ip/include/ArrayTemplate.hh @@ -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 +#include +#include + + +template +class ArrayTemplate +{ + public: + ArrayTemplate(const SourceType& source) + : source(source) + { + } + + ArrayTemplate(const ArrayTemplate&) = delete; + ArrayTemplate& operator=(const ArrayTemplate&) = delete; + + private: + const SourceType& source; +}; + + +#endif +