swig icon indicating copy to clipboard operation
swig copied to clipboard

calling void functions without arguments now needs ()

Open KrisThielemans opened this issue 9 years ago • 3 comments

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,'()',{}));

KrisThielemans avatar Aug 27 '15 11:08 KrisThielemans

This may well have been introduced in one of my commits. We need functional unittests.

jgillis avatar Aug 27 '15 13:08 jgillis

This is no longer the case (tested with #96 but could have been fixed before that).

KrisThielemans avatar Dec 30 '21 21:12 KrisThielemans

re-opened as the exact test-case still failed.

The problem sits in using [varargout{1}]

KrisThielemans avatar Dec 30 '21 21:12 KrisThielemans