PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/ttn-post-libtool-1-4-3-upgrade/SWIG/Examples/python/pointer/runme.py

#
Python | 44 lines | 22 code | 13 blank | 9 comment | 0 complexity | 3d7925b6b318eb7ce75179820841a1aa MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. # file: example.py
  2. import example;
  3. # First create some objects using the pointer library.
  4. print "Testing the pointer library";
  5. a = example.new_intp();
  6. b = example.new_intp();
  7. c = example.new_intp();
  8. example.intp_assign(a,37);
  9. example.intp_assign(b,42);
  10. print " a =",a
  11. print " b =",b
  12. print " c =",c
  13. # Call the add() function with some pointers
  14. example.add(a,b,c)
  15. # Now get the result
  16. r = example.intp_value(c)
  17. print " 37 + 42 =",r
  18. # Clean up the pointers
  19. example.delete_intp(a)
  20. example.delete_intp(b)
  21. example.delete_intp(c)
  22. # Now try the typemap library
  23. # This should be much easier. Now how it is no longer
  24. # necessary to manufacture pointers.
  25. print "Trying the typemap library";
  26. r = example.sub(37,42)
  27. print " 37 - 42 =",r
  28. # Now try the version with multiple return values
  29. print "Testing multiple return values";
  30. q,r = example.divide(42,37)
  31. print " 42/37 = %d remainder %d" % (q,r)