Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress destructor calls #1877

Open
msys5 opened this issue Oct 9, 2024 · 0 comments
Open

Suppress destructor calls #1877

msys5 opened this issue Oct 9, 2024 · 0 comments

Comments

@msys5
Copy link

msys5 commented Oct 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant