Hey, sorry for the lacking information.<br><br>May I declare it as this instead:<br><br>C++ Class<br>class GameObjectManager<br>{<br>    map&lt;GameObject*, Data&gt; a_map; // this map has &quot;nothing&quot; to do with python dict<br>
   GameObject* createGameObject(id)<br>   {<br>      Gameobject* obj = new Gameobject(id);<br>      a_map[ obj ] = ...some data...<br>      return obj;<br>    }<br><br><br>   callPython()<br>  {<br>      // get game object from map<br>
      obj = a_map.getgameobject()<br>      boost::python::get_override(&quot;callbackFunction&quot;)(boost::python::object(boost::python::ptr(obj)));<br>  }<br><br>}; // end of class<br><br>The python class:<br><br><br>class myRandomClass:<br>
   def __init(self, the_c++_GameobjectManager_pointer):<br>     self.manager = the_c++_GameobjectManager_pointer<br>     gameobject = self.manager.createGameObject(1) #self.manager.createGameObject() returns a pointer to the gameobject created in c++<br>
     self.mylist[gameobject] = ..some data..<br><br>   def callPython(self, gameobj): # at some point, c++ will call this function and pass the game object we created above with id 1<br>    for x in self.mylist.keys():<br>
      print(x == gameobj)         # True<br>      print(gameobj in mylist)    # False<br><br>So basically the c++ class and python class have their own dict but I want them to have the <b>same </b>address value in their keys .. is it possible??<br>
<br>It seems, in c++ the key is the address of the game object and in Python it some other address (but they basically point to the same object/memory). Is there any way around this <u>without</u> changing the type of the key being used, i.e. keep the key as a pointer.<br>
<br><br><br><br><div class="gmail_quote">On Fri, Sep 24, 2010 at 4:27 PM, Stefan Seefeld <span dir="ltr">&lt;<a href="mailto:seefeld@sympatico.ca">seefeld@sympatico.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
 Simon,<br>
<br>
I don&#39;t quite understand what you are trying to do. Please provide a little more detail. Your current mail requires far too much second-guessing to be useful.<div class="im"><br>
<br>
On 09/24/2010 10:08 AM, Simon W wrote:<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
Hi,<br>
<br>
Im really scared because I fear a fundamental issue concerning the script system in my game engine.<br>
<br>
<br>
In C++, I have a class. In my class I map data to GameObject like:<br>
<br>
*class<br>
{<br>
    map&lt;GameObject*, Data&gt; .....<br></div>
}*<br>
</blockquote>
<br>
OK. (Naming this class would help the discussion, though.)<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
<br>
As you see, I use the pointer as key.<br>
<br>
When I from c++, in the same class, call a python function I pass the key like this:<br>
<br>
*class::callPythonFunctions()<br>
{<br>
   boost::python::get_override(&quot;callbackFunction&quot;)(boost::python::object(boost::python::ptr(gameobject))); // the variable /gameobj /is of type GameObject*<br>
}<br></div>
*<br>
</blockquote>
<br>
OK.<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
<br>
When I recieve the call in python I do some checks like this:<br>
<br>
*def callbackFunction(self, gameobj):<br>
   for x in self.mydict.keys():<br>
     print(&quot;Checking&quot;)<br>
     print(gameobj == self.mydict)<br></div>
     print(gameobj in self.mydict)*<br>
</blockquote>
<br>
This looks wrong. You iterate over &#39;x&#39;, but don&#39;t use it in the loop. May I assume that &#39;mydict&#39; relates to the above map&lt;GameObject*, Data&gt; in the unnamed class ?<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
<br>
<br>
The above will print something like:<br>
/....<br>
Checking<br>
True<br>
False<br></div>
.../<br>
</blockquote>
<br>
This suggests that &#39;gameobj&#39; compares equal to the &#39;mydict&#39; object, but that it is not itself included in the sequence returned by mydict.keys().<div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I do have a overloaded == operator. But how can I fix so that python checks for my pointer and not the PyObject* pointer ?<br>
</blockquote>
<br></div>
What type do you consider providing an operator== for ?<br>
<br>
    Stefan<br><font color="#888888">
<br>
<br>
-- <br>
<br>
      ...ich hab&#39; noch einen Koffer in Berlin...<br>
<br>
_______________________________________________<br>
Cplusplus-sig mailing list<br>
<a href="mailto:Cplusplus-sig@python.org" target="_blank">Cplusplus-sig@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/cplusplus-sig" target="_blank">http://mail.python.org/mailman/listinfo/cplusplus-sig</a><br>
</font></blockquote></div><br>