PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/tcl/pointer/runme.tcl

#
TCL | 47 lines | 24 code | 14 blank | 9 comment | 0 complexity | 43b0e4f751157b23b83e1e456912eff8 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. # file: runme.tcl
  2. catch { load ./example[info sharedlibextension] example}
  3. # First create some objects using the pointer library.
  4. puts "Testing the pointer library"
  5. set a [new_intp]
  6. set b [new_intp]
  7. set c [new_intp] ;# Memory for result
  8. intp_assign $a 37
  9. intp_assign $b 42
  10. puts " a = $a"
  11. puts " b = $b"
  12. puts " c = $c"
  13. # Call the add() function with some pointers
  14. add $a $b $c
  15. # Now get the result
  16. set r [intp_value $c]
  17. puts " 37 + 42 = $r"
  18. # Clean up the pointers
  19. delete_intp $a
  20. delete_intp $b
  21. 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. puts "Trying the typemap library"
  26. set r [sub 37 42]
  27. puts " 37 - 42 = $r"
  28. # Now try the version with multiple return values
  29. puts "Testing multiple return values"
  30. set qr [divide 42 37]
  31. set q [lindex $qr 0]
  32. set r [lindex $qr 1]
  33. puts " 42/37 = $q remainder $r"