Biohazrd
Biohazrd copied to clipboard
Add support for runtime deletion of C++ objects
In C++, deletion (as in the delete
operator) and destruction (as in ~MyStruct
) are separate concepts and are handled differently depending on the context.
In our current scheme, deletion is only required if you need to delete
an object in C# which was allocated on the heap in C++.
We need to be careful of how we surface this, because the distinction here is not normally something most C++ developers worry about, much less C# developers. (The main distinction here is that objects are destroyed in C++ in different ways depending on whether they are allocated on the global heap, placed with placement new, or allocated on the stack. There's also concerns for how overloaded delete
operators get called. Normally you only care about these things if you're using placement new, which is fairly niche and usually hidden behind macros.)
(Note to self: See notes for some details on how this is implemented in various ABIs.)
(Note to self: See notes for some details on how this is implemented in various ABIs.)
I'm sure those notes are still somewhere, lol.
I ended up digging around quite a bit on the Microsoft ABI for destruction here:
https://github.com/MochiLibraries/Biohazrd/issues/243