Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Using XS To Wrap A C++ Smart Pointer

by williams (Beadle)
on Sep 29, 2009 at 18:39 UTC ( #798174=note: print w/replies, xml ) Need Help??

in reply to Using XS To Wrap A C++ Smart Pointer

I was able to follow the typemap suggestion, adding a mapping that eliminates most cases of the repeated code I wanted to avoid. It's slightly nefarious, since I'm sneaking around the back of the smart pointer, accessing the underlying pointer directly, but I think it's justified within these internals.

An issue I didn't mention in the original post was that the smart pointers were pointing at objects belonging to a large class hierarchy. I'm using boost::shared_ptr for this, since it provides nice support for implicit conversions from smart pointers to derived classes, to smart pointers to their base classes. Dealing with this in the XS required writing a small class hierarchy that wraps these smart pointers, but restores the original class hierarchy that the smart pointers concealed.

Thanks for the help.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://798174]
[Eily]: marto I clearly don't have the thread knowledge to understand the importance of that example
[choroba]: the related discussion on Hacker news is interesting
[choroba]: not so many Perl haters so far

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2017-07-26 14:18 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (396 votes). Check out past polls.