PageRenderTime 35ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/ruby/pointer/runme.rb

#
Ruby | 45 lines | 22 code | 14 blank | 9 comment | 0 complexity | b4c18408acc412b334b3c2b1f5962936 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. # file: runme.rb
  2. require 'example'
  3. # First create some objects using the pointer library.
  4. print "Testing the pointer library\n"
  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}\n"
  11. print " b = #{b}\n"
  12. print " c = #{c}\n"
  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}\n"
  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\n"
  26. r = Example::sub(37, 42)
  27. print " 37 - 42 = #{r}\n"
  28. # Now try the version with multiple return values
  29. print "Testing multiple return values\n"
  30. q, r = Example::divide(42, 37)
  31. print " 42/37 = #{q} remainder #{r}\n"