summaryrefslogtreecommitdiff
path: root/ext/dl/lib/dl/closure.rb
blob: eca941dfbc2e0dd5ec647247aac05a37cf10c3b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require 'dl'

module DL
  class Closure
    attr_reader :ctype
    attr_reader :args

    class BlockCaller < DL::Closure
      def initialize ctype, args, abi = DL::Function::DEFAULT, &block
        super(ctype, args, abi)
        @block = block
      end

      def call *args
        @block.call(*args)
      end
    end
  end
end