this should fix obj.this on 64-bits architectures

This commit is contained in:
rdb 2012-03-09 21:32:47 +00:00
parent 95c7d74a4d
commit a96c08b5c8
2 changed files with 3 additions and 3 deletions

View File

@ -78,9 +78,9 @@ write_code(ostream &out) {
<< " PyObject *in_dict = ((PyInstanceObject *)obj)->in_dict;\n"
<< " if (in_dict != (PyObject *)NULL && PyDict_Check(in_dict)) {\n"
<< " PyObject *thisobj = PyDict_GetItemString(in_dict, \"this\");\n"
<< " if (thisobj != (PyObject *)NULL && PyInt_Check(thisobj)) {\n"
<< " if (thisobj != (PyObject *)NULL && PyLong_Check(thisobj)) {\n"
<< " (*addr) = ("
<< _pointer_type->get_local_name(&parser) << ")PyInt_AsLong(thisobj);\n"
<< _pointer_type->get_local_name(&parser) << ")PyLong_AsVoidPtr(thisobj);\n"
<< " return 1;\n"
<< " }\n"
<< " }\n"

View File

@ -73,7 +73,7 @@ write_code(ostream &out) {
<< " PyObject *classobj = " << classobj_func << "();\n"
<< " PyInstanceObject *instance = (PyInstanceObject *)PyInstance_New(classobj, (PyObject *)NULL, (PyObject *)NULL);\n"
<< " if (instance != (PyInstanceObject *)NULL) {\n"
<< " PyObject *thisptr = PyInt_FromLong((long)addr);\n"
<< " PyObject *thisptr = PyLong_FromVoidPtr((void*)addr);\n"
<< " PyDict_SetItemString(instance->in_dict, \"this\", thisptr);\n"
<< " }\n"
<< " return (PyObject *)instance;\n"