PageRenderTime 15ms CodeModel.GetById 2ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 1ms

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

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