Flowdock
method

set_callback_internal

Importance_0
v1_9_3_125 - Show latest stable - 0 notes - Class: DL
set_callback_internal(proc_entry, addr_entry, argc, ty, abi = nil, &cbp) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File ext/dl/lib/dl/callback.rb, line 30
  def set_callback_internal(proc_entry, addr_entry, argc, ty, abi = nil, &cbp)
    if( argc < 0 )
      raise(ArgumentError, "arity should not be less than 0.")
    end
    addr = nil

    if DL.fiddle?
      abi ||= Fiddle::Function::DEFAULT
      closure = Fiddle::Closure::BlockCaller.new(ty, [TYPE_VOIDP] * argc, abi, &cbp)
      proc_entry[closure.to_i] = closure
      addr = closure.to_i
    else
      SEM.synchronize{
        ary = proc_entry[ty]
        (0...MAX_CALLBACK).each{|n|
          idx = (n * DLSTACK_SIZE) + argc
          if( ary[idx].nil? )
            ary[idx] = cbp
            addr = addr_entry[ty][idx]
            break
          end
        }
      }
    end

    addr
  end
Register or log in to add new notes.