Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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.

Jim


Comment on Re: Using XS To Wrap A C++ Smart Pointer
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://798174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-07-24 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (158 votes), past polls