Suppress destructor calls
msys5 opened this issue · 1 comments
msys5 commented
Brief Description
The result class implemented in the pimpl idiom is exported as ValueType with the CS_VALUE_TYPE macro, as shown below.
class LIB_EXPORT CS_VALUE_TYPE result {
class handle;
private:
handle *_pimpl;
public:
bool is_ok() const;
}
class LIB_EXPORT lib {
public:
result initialize();
}
Then, when there is an initialize() function that returns this result class, the output C# code is as follows.
public global::Result Initialize()
{
var ___ret = new global::Result.__Internal();
__Internal.Initialize(__Instance, new IntPtr(&___ret));
var _____ret = global::Result.__CreateInstance(___ret);
global::Result.__Internal.dtor(new __IntPtr(&___ret));
return _____ret;
}
Since the result class is implemented in the pimpl idiom, calling the destructor at global::Result.__Internal.dtor(new __IntPtr(&___ret)); will disable the __pimpl members on the c++ side.
This situation requires an option to suppress destructor calls.
tritao commented
Feel free to send a PR with an option for this.