PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 1ms

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

#
Python | 34 lines | 26 code | 7 blank | 1 comment | 1 complexity | 35c1ff816f088c8ecb89aa4cd0d13f41 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  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