From: Bob H. <bh...@co...> - 2010-04-16 18:59:45
|
I have a situation where I have a global function that returns a reference to a list of items: const ComponentList& current_selection(...); This is being done for performance reasons. However, it is a somewhat dangerous action because a call to another function clear_selections() will render the reference invalid. While this is going to be documented, I want to alter the way SWIG handles this so that users of the scripting interface (Python) are less likely to shoot themselves in the foot. I would like to alter the way this is handled so that a deep copy of the list is passed to the scripting language instead of a volatile reference. My question, then, is how should I approach this within SWIG to force a deep copy, e.g.: ComponentList list = current_selection(); within the wrapper code? I've read all the way through sections 5 and 6 of the documentation, but encountered that might nothing to trip the lightbulb over my head. Do I need to completely override the wrapping for the current_selection() function? |