-
-
Notifications
You must be signed in to change notification settings - Fork 686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrapping of member functions that are passed and/or return std:string goes wonky #4779
Comments
Just wondering, should there be a |
I think we generally want to avoid the use of |
I would like to see a minimal example where |
I tired compiling with wrapping enabled and ran into issue with the precompiled binaries on Mac ARM: |
@aylward In itkSpatialObjectProperty.i I see the following:
Which apply some "funky" input output with then string reference parameter is "value". This likely is generated from the following code block: ITK/Wrapping/Generators/SwigInterface/igenerator.py Lines 1597 to 1611 in e93fa19
I conjecture the following line is causing this additional "apply" to corrupt the behavior of the other "std::string" parameters:
If this signature is needed, name the parameter something like "inout_value". Additionally I recommend return values be "std::string" and input arguments be "const std::string &". There is no current wrapping enabled/tested for "string_value". |
Outstanding! I will create a PR to start testing this. Since we're moving towards ITK 6.0, I will break backward compatibility in ITKSpatialObjects, and update its API to use Get/SetMacros and appropriate variable types (e.g., no double * variables). I'll follow you suggestion of return by value and pass by const reference. Thanks!!! |
I'm glad to see you found the source of this issue, @blowekamp This commit appears to have introduced this behavior: 32df266 "ENH: Allow to use methods which pass std::string by reference from python", Michka Popoff (@iMichka), Jun 28, 2014. Saying:
Is the old bug report ITK-3285 still available somewhere? Given that the bug report (ITK-3285) and the commit are both more than 10 years old, is this |
@hjmjohnson @thewtex is the old ITK JIRA still available somewhere? |
Found it! https://insightsoftwareconsortium.atlassian.net/browse/ITK-3285 "Allow passing std::string by reference to functions", June 27, 2014. Ironically, it seems like this commit effectively disallows passing std::string by reference! (As it triggered Stephen to change pass by reference to pass by value.) But I guess I just don't understand it well enough! |
The issues are demonstrated in #4776
This documentation, though old, might be relevant...
https://www.swig.org/Doc1.3/Arguments.html#Arguments_nn2
That documented feature would cause a function in C++ that returns a void to wrap to a python function that returns a value - hence causing the SetTagValueString to appear to return a value in python.
https://www.swig.org/Doc1.3/SWIG.html#SWIG_nn23
So, that is where the std::string * references are coming from.
Summary
I suspect there is a bug in our SWIG wrapping specification for these reasons and because new SWIG should handled std::string fine and these wonkynesses shouldn't be happening.
The text was updated successfully, but these errors were encountered: