Accept a Python sequence instead of an R3 instance
A SWIG typemap
is added to map a Python sequence to an R3
instance (Wrap/Swig/r3_typemap.i
).
This change allows the following Python code, for instance:
import bornagain as ba
sample = ba.Sample()
v0 = (1, 2, 0)
sample.setExternalField(v0)
while the C++ signature of Sample::setExternalField
is
void setExternalField(const R3& ext_field);
Note that this method works only for functions or methods which are not overloaded. Overloaded functions or methods must be explicitly 'extended' in SWIG to accept a Python sequence instead of an R3
instance.
See https://www.swig.org/Doc1.3/Typemaps.html#Typemaps_overloading.
Additionally, the code is improved to avoid copying R3
arguments when possible.
A const reference is used instead.
Related to issue #111
Edited by Ammar Nejati