swig
swig copied to clipboard
calling void functions without arguments now needs ()
we have a C++ member function wrapped that takes no arguments. One of our users used to be able to call this in matlab without brackets, but this now throws an error: One or more output arguments not assigned during call to "voidvoidtest_wrap". It does work with brackets though. It seems that in the recent update to subsref this behaviour changed. Note that it still works without brackets for stand-alone functions or static member functions.
To reproduce this:
%module testit %{ #include <stdio.h> %}
%inline %{ void testfunction() { printf("OK\n"); };
class testclass { public: static void statictestfunction() { printf("OK\n"); }; testclass() {} // this is the one with the problem void membertestfunction() { printf("OK\n"); }; }; %}
With the above interface file, I get in matlab
a=testit.testclass; a.membertestfunction() OK a.membertestfunction OK One or more output arguments not assigned during call to "voidvoidtest_wrap".
Error in testit.testclass/testfunction (line 13) [varargout{1:nargout}] = voidvoidtest_wrap(6, self, varargin{:});
Error in SwigRef/subsref (line 13) [varargout{1}] = builtin('subsref',self,substruct('.',s.subs,'()',{}));
This may well have been introduced in one of my commits. We need functional unittests.
This is no longer the case (tested with #96 but could have been fixed before that).
re-opened as the exact test-case still failed.
The problem sits in using [varargout{1}]