From: Josh C. <jc...@nc...> - 2009-12-16 15:45:22
|
On Wed, 16 Dec 2009, Robert Lupton the Good wrote: > If I use return-by-const-reference in C++ the recipient cannot modify > the underlying data (she can end up with a dangling reference, but > that's a different problem). If I swig the code, the user *can* > modify the underlying object --- swig has cast away the const. > > This is hinted at in the manual: >> In Python, there is no detailed distinction like this--specifically, >> there are only "objects". There are no pointers, references, arrays, >> and so forth. Because of this, SWIG unifies all of these types >> together in the wrapper code > > In this case the "BBox" is small, so I can modify the class to return > it by value but it'd be nice if swig generated a warning (and there > was a note in the manual). The manual does discuss this explicitly: http://www.swig.org/Doc1.3/SWIGPlus.html#SWIGPlus_nn37 I would like to see const supported. I imagine that it can be done without inordinate effort, but that's easy to say when you're not a developer. Josh |