Closed ninotarantino closed 2 months ago
Thanks for reporting this. I believe there was a fix related to this that is not in 19.7.1. Wondering if you tried the latest trick and still saw the issue?
Hey Hong. Just tried with the latest master
: c2c068a0 (June 5, 2024) and I'm still seeing the issue.
Thanks for your quick response, Nino! Would you give it a try using this: https://github.com/nasa/trick/tree/1703-error-extraneous-endif-and-incorrect-namespaces-after-trick-1679 ? Thanks!
I'm still seeing the issue on that branch too, unfortunately.
Thanks for testing. Will investigate.
Thanks for looking into this! For anyone else's future reference, the current work-around is to manually add the SWIG template in source code. For the example I posted, that would be something like
// somesource.hh
#ifdef SWIG
%template(Nino_double3) Nino<double[3]>;
#endif
what if you rewrote the template to take, instead of <double[3]>, <double, 3>?
This is for a generic class that can take scalars, pointers, and arrays as template parameters. I could do that, but there'd need to be a decent amount of rewriting to handle arrays since the class as written stores a reference to the base data. I could make the underlying data always be a pointer, but I wanted to avoid that so I wouldn't need to check for null pointers.
Either way, I do have a workaround right now that I'm fine with.
@ninotarantino Thanks for sharing the workaround. If you get a chance, please give it a try again using https://github.com/nasa/trick/tree/1703-error-extraneous-endif-and-incorrect-namespaces-after-trick-1679 as a fix for array was put in
No luck unfortunately. I think there's some regex patterns in convert_swig
that still need to be updated for it to catch a template of an array type.
No luck unfortunately. I think there's some regex patterns in
convert_swig
that still need to be updated for it to catch a template of an array type.
Thought a specific fix for array type was put in convert_swig
. Will double check. Thanks for testing!
@ninotarantino Patrick told me that the array type issue will be addressed in a different ticket. Sorry for giving you the incorrect info. Will let you know once the issue is fixed.
@ninotarantino https://github.com/nasa/trick/pull/1742 is for addressing array type. Please give it a try whenever you get a chance. Thanks!
@hchen99 Awesome, my example I posted earlier works! I also tried with multidimensional types (ex Type<double[3][3]>
) and that works as well. Looks like that fixed the problem.
@hchen99 Awesome, my example I posted earlier works! I also tried with multidimensional types (ex
Type<double[3][3]>
) and that works as well. Looks like that fixed the problem.
Great to hear! Thank you so much for testing and confirming!
The Problem
Suppose I have a source file called
nino.hh
like the following:and a Trick sim with the following
S_define
:I get the build error:
The sim will build for any other kind of template parameter used for the
Nino
class: a scalar, pointer, some other class, etc. It's only tripping up on C-style arrays, ex.double[3]
,int[5]
, etc.The Bug
If we take a look at
S_source_py.i
, that sim object looks like this:We're missing a
#define TRICK_SWIG_TEMPLATE_NinoSimObject_nino
statement below thenino
variable declaration. There should also be lines further down that look like the following, but they're also missing:If I manually add those lines into
S_source_py.i
the sim will build and run.Testing
I confirmed this bug using Trick 19.7.1 on: