[C++-sig] use of hash to map c++ pointers with python objects

Renato Araujo renatox at gmail.com
Fri Aug 28 23:32:25 CEST 2009


Hi all,


I'm working on PySide[1] and we have a problem with map between c++
pointers and PyObject.

In this section of FAQ:
http://www.boost.org/doc/libs/1_40_0/libs/python/doc/v2/faq.html#xref,
they give some examples on how to handle this kind of problem. But the
point is: dynamic_cast does not work between shared libraries. My
wrapper class is not visible to another library then the dynamic_cast
fails.

Then I tried implement a hash table to map c++ pointers and python
objects, but in some point of the code I received the pointer in
another class representation and this moves the pointer address to
another region of memory, causing a mess in my hash. I would like to
know if someone has any idea about how to solve this problem. How can
I map a c++ pointer to a PyObject between libraries without use
dynamic_cast.


I have attached a small use case for this case.



Renato Araujo Oliveira Filho
[1] PySide = http://pyside.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 1696 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090828/89a6c672/attachment.cpp>


More information about the Cplusplus-sig mailing list