/trunk/Examples/test-suite/python/swigobject_runme.py

# · Python · 34 lines · 23 code · 10 blank · 1 comment · 3 complexity · 35c1ff816f088c8ecb89aa4cd0d13f41 MD5 · raw file

  1. from swigobject import *
  2. a = A()
  3. a1 = a_ptr(a)
  4. a2 = a_ptr(a)
  5. if a1.this != a2.this:
  6. raise RuntimeError
  7. lthis = long(a.this)
  8. # match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p
  9. xstr1 = "%016X" % (lthis,)
  10. xstr1 = str.lstrip(xstr1, '0')
  11. xstr2 = pointer_str(a)
  12. xstr2 = str.replace(xstr2, "0x", "")
  13. xstr2 = str.replace(xstr2, "0X", "")
  14. xstr2 = str.lstrip(xstr2, '0')
  15. xstr2 = str.upper(xstr2)
  16. if xstr1 != xstr2:
  17. print xstr1, xstr2
  18. raise RuntimeError
  19. s = str(a.this)
  20. r = repr(a.this)
  21. v1 = v_ptr(a)
  22. v2 = v_ptr(a)
  23. if long(v1) != long(v2):
  24. raise RuntimeError