We have run up against a problem with code generated by Py++ that involves a
very specific combination of circumstances. The attached code shows how to
repeat the errors, but the short explanation is that combining the following
results in code that does not compile:
* A class with a non-public destructor
* A const member function in that class that returns one or more values
through by-reference parameters
* A function transformation to get the by-reference values returned as a
tuple
What happens is that the wrapper function generated to create the tuple
takes its "self" argument by const reference rather than by reference or by
pointer. For reasons that I have not yet determined, Boost.Python wants to
delete objects that are passed by const reference in this scenario. For
regular r-values, that *might* be OK, but not in this case for two reasons:
1) the parameter that would be deleted is the C++ object on which we are
operating and 2) the object's class has no public destructor.
Is there a workaround that we can apply to handle this situation? So far, we
have not been able to figure out any other use of a function transformation
that would address this case. What we need to do is remove the const
modifier from the "self" parameter.
Strictly speaking, I am not sure that this is a Py++ problem. A very closely
related issue arose a while back where I wanted to generate code for a
method that takes an object by const reference that has no public
destructor. Boost.Python decides that the r-value being passed by const
reference needs to be deleted explicitly, but that cannot happen because the
destructor is not public. The object destruction should not need to happen
anyway.
-Patrick
--
Patrick L. Hartling
Senior Software Engineer, Priority 5
http://www.priority5.com/
|