method

new

Importance_0
v1_9_3_125 - Show latest stable - 0 notes - Class: Function
new(cfunc, argtypes, abi = nil, &block) 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/func.rb, line 14
    def initialize cfunc, argtypes, abi = nil, &block
      if DL.fiddle?
        abi ||= Fiddle::Function::DEFAULT
        if block_given?
          @cfunc = Class.new(Fiddle::Closure) {
            define_method(:call, block)
          }.new(cfunc.ctype, argtypes)
        else
          @cfunc  = cfunc
        end

        @args   = argtypes
        super(@cfunc, @args.reject { |x| x == TYPE_VOID }, cfunc.ctype, abi)
      else
        @cfunc = cfunc
        @stack = Stack.new(argtypes.collect{|ty| ty.abs})
        if( @cfunc.ctype < 0 )
          @cfunc.ctype = @cfunc.ctype.abs
          @unsigned = true
        else
          @unsigned = false
        end
        if block_given?
          bind(&block)
        end
      end
    end
Register or log in to add new notes.