You could do the double indirection thing.
That is, instead of passing the SV that wraps your C++ object to the Perl code, pass an SvRV that points to that SV. Then your Perl code would have to indirect through the SvRV to get at the object
my $cppOref = shift; return unless $$cppOref; $$cppOref->whatever
That way, your C++ destructor can undef the SV, and any copies of the SvRV that the Perl code has retain will point to undef. It won't stop someone making a copy of the dereferenced SV: my $sneaky = $$cppOref; and falling in a heap by trying to use it later, but that's an education thing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl embedded in C++: how to undefine perl objects that are blessed references to C++ objects when the C++ object destructs
by kingkongrevenge (Scribe) on Sep 19, 2009 at 15:49 UTC | |
by BrowserUk (Patriarch) on Sep 19, 2009 at 16:01 UTC | |
by kingkongrevenge (Scribe) on Sep 21, 2009 at 20:19 UTC | |
by BrowserUk (Patriarch) on Sep 21, 2009 at 22:39 UTC | |
by kingkongrevenge (Scribe) on Sep 21, 2009 at 23:58 UTC |