fix hex pointer conversion
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7021 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
00ea3d5ae8
commit
32d5addaa6
3 changed files with 5 additions and 3 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
const char* pointer_str(A *a){
|
const char* pointer_str(A *a){
|
||||||
static char result[1024];
|
static char result[1024];
|
||||||
sprintf(result,"%x",a);
|
sprintf(result,"%p",a);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,12 @@ if a1.this != a2.this:
|
||||||
|
|
||||||
|
|
||||||
lthis = long(a.this)
|
lthis = long(a.this)
|
||||||
xstr1 = "%x" % (lthis,)
|
xstr1 = "0x%x" % (lthis,)
|
||||||
xstr2 = pointer_str(a)
|
xstr2 = pointer_str(a)
|
||||||
|
|
||||||
|
print hex(lthis)
|
||||||
if xstr1 != xstr2:
|
if xstr1 != xstr2:
|
||||||
|
print xstr1, xstr2
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
s = str(a.this)
|
s = str(a.this)
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ SWIGRUNTIME PyObject *
|
||||||
PySwigObject_hex(PySwigObject *v)
|
PySwigObject_hex(PySwigObject *v)
|
||||||
{
|
{
|
||||||
char buf[100];
|
char buf[100];
|
||||||
PyOS_snprintf(buf, sizeof(buf), "0x%lx", (unsigned long)v->ptr);
|
PyOS_snprintf(buf, sizeof(buf), "%p", v->ptr);
|
||||||
return PyString_FromString(buf);
|
return PyString_FromString(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue