PageRenderTime 38ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/ruby/funcptr2/runme.rb

#
Ruby | 22 lines | 16 code | 5 blank | 1 comment | 0 complexity | 4749b29f106bcb33953d488b865697bc MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. require 'example'
  2. a = 37
  3. b = 42
  4. # Now call our C function with a bunch of callbacks
  5. puts "Trying some C callback functions"
  6. puts " a = #{a}"
  7. puts " b = #{b}"
  8. puts " ADD(a,b) = #{Example.do_op(a,b,Example::ADD)}"
  9. puts " SUB(a,b) = #{Example.do_op(a,b,Example::SUB)}"
  10. puts " MUL(a,b) = #{Example.do_op(a,b,Example::MUL)}"
  11. puts "Here is what the C callback function objects look like in Ruby"
  12. puts " ADD = #{Example::ADD}"
  13. puts " SUB = #{Example::SUB}"
  14. puts " MUL = #{Example::MUL}"
  15. puts "Call the functions directly..."
  16. puts " add(a,b) = #{Example.add(a,b)}"
  17. puts " sub(a,b) = #{Example.sub(a,b)}"