We moved from SWIG version 1.3.31 to 1.3.39 and found out, that SWIG now introduced the following sanity check:
SWIG_check_num_args
By doing so we can not write any wraper code anymore taking variable number of arguments.
For example, we wrote some typemap
%typemap\(in\) \(int n, double\* x\) \(double\*\) \{ double \*y; double m, key; int n, k=0; const char \*text; size\_t nbytes; int i; /\* get number of arguments \*/ n = lua\_gettop\(L\)-1; $1 = n; y = new double\[n\]; /\* loop through each argument \*/ for \(i = 0; i < n; i++\) \{ y\[i\]= lua\_tonumber\(L, i+2\); \} nbytes = n\*sizeof\(double\); $2 = \(double\*\) lua\_newuserdata\(L, nbytes\); for \(k=0; k<n; k++\) \{ $2\[k\] = y\[k\]; \} delete y; \}
This typemap wraps a method
void Read(int n, double * data);
which is interpreted in Lua as
void Read(double data1, double data2 , ... );
Off course we could use
%varargs
but this produces horrible wrapper code (think of 3000 possible arguments - for each combination an individual wrapper routine would be created).
Is it possible to make this configurable somehow?
For now we switched back to 1.3.31
You can put this in your interface file:
It's rather a crude solution though, and disables it for all wrapped functions in the module.
https://github.com/swig/swig/pull/189 includes an "unlimited args" setting which I think would provide a cleaner solution to this.