Class | DL::CarriedFunction
In: | dl/lib/dl/func.rb
Parent: | Function

### Methods

bind_at_call create_carrier new

### Public Class methods

new(cfunc, argtypes, n)

[Source]

    # File dl/lib/dl/func.rb, line 111
        def initialize(cfunc, argtypes, n)
          super(cfunc, argtypes)
          @carrier = []
          @index = n
          @mutex = Mutex.new
        end

### Public Instance methods

bind_at_call(&block)

[Source]

    # File dl/lib/dl/func.rb, line 126
        def bind_at_call(&block)
          userdata = @carrier[-1]
          userdata[0].push(block)
          bind{|*args|
            ptr = args[@index]
            if( !ptr )
              raise(RuntimeError, "The index of userdata should be lower than #{args.size}.")
            end
            userdata = dlunwrap(Integer(ptr))
            args[@index] = userdata[1]
            userdata[0][0].call(*args)
          }
          @mutex.unlock()
        end

create_carrier(data)

[Source]

    # File dl/lib/dl/func.rb, line 118
        def create_carrier(data)
          ary = []
          userdata = [ary, data]
          @mutex.lock()
          @carrier.push(userdata)
          return dlwrap(userdata)
        end

[Validate]