In Files

  • dl/dl.c
  • dl/lib/dl/callback.rb
  • dl/lib/dl/cparser.rb
  • dl/lib/dl/func.rb
  • dl/lib/dl/import.rb
  • dl/lib/dl/pack.rb
  • dl/lib/dl/stack.rb
  • dl/lib/dl/struct.rb
  • dl/lib/dl/types.rb
  • dl/lib/dl/value.rb
  • dl/win32/lib/Win32API.rb

DL

Public Class Methods

dlopen(*args) click to toggle source
 
               VALUE
rb_dl_dlopen(int argc, VALUE argv[], VALUE self)
{
    return rb_class_new_instance(argc, argv, rb_cDLHandle);
}
            
dlunwrap(p1) click to toggle source
 
               VALUE
rb_dl_ptr2value(VALUE self, VALUE addr)
{
    rb_secure(4);
    return (VALUE)NUM2PTR(addr);
}
            
dlwrap(p1) click to toggle source
 
               VALUE
rb_dl_value2ptr(VALUE self, VALUE val)
{
    return PTR2NUM((void*)val);
}
            
free(p1) click to toggle source
 
               VALUE
rb_dl_free(VALUE self, VALUE addr)
{
    void *ptr = NUM2PTR(addr);

    rb_secure(4);
    ruby_xfree(ptr);
    return Qnil;
}
            
malloc click to toggle source

Allocate size bytes of memory and return the integer memory address for the allocated memory.

 
               VALUE
rb_dl_malloc(VALUE self, VALUE size)
{
    void *ptr;

    rb_secure(4);
    ptr = (void*)ruby_xmalloc(NUM2INT(size));
    return PTR2NUM(ptr);
}
            
realloc(addr, size) click to toggle source

Change the size of the memory allocated at the memory location addr to size bytes. Returns the memory address of the reallocated memory, which may be different than the address passed in.

 
               VALUE
rb_dl_realloc(VALUE self, VALUE addr, VALUE size)
{
    void *ptr = NUM2PTR(addr);

    rb_secure(4);
    ptr = (void*)ruby_xrealloc(ptr, NUM2INT(size));
    return PTR2NUM(ptr);
}
            

Public Instance Methods

remove_callback(addr, ctype = nil) click to toggle source
remove_callback_internal(proc_entry, addr_entry, addr, ctype = nil) click to toggle source
 
               # File dl/lib/dl/callback.rb, line 34
def remove_callback_internal(proc_entry, addr_entry, addr, ctype = nil)
  index = nil
  if( ctype )
    addr_entry[ctype].each_with_index{|xaddr, idx|
      if( xaddr == addr )
        index = idx
      end
    }
  else
    addr_entry.each{|ty,entry|
      entry.each_with_index{|xaddr, idx|
        if( xaddr == addr )
          index = idx
        end
      }
    }
  end
  if( index and proc_entry[ctype][index] )
    proc_entry[ctype][index] = nil
    return true
  else
    return false
  end
end
            
remove_cdecl_callback(addr, ctype = nil) click to toggle source
 
               # File dl/lib/dl/callback.rb, line 59
def remove_cdecl_callback(addr, ctype = nil)
  remove_callback_internal(CdeclCallbackProcs, CdeclCallbackAddrs, addr, ctype)
end
            
Also aliased as: remove_callback
remove_stdcall_callback(addr, ctype = nil) click to toggle source
 
               # File dl/lib/dl/callback.rb, line 63
def remove_stdcall_callback(addr, ctype = nil)
  remove_callback_internal(StdcallCallbackProcs, StdcallCallbackAddrs, addr, ctype)
end
            
set_callback(ty, argc, &cbp) click to toggle source
Alias for: set_cdecl_callback
set_callback_internal(proc_entry, addr_entry, argc, ty, &cbp) click to toggle source
 
               # File dl/lib/dl/callback.rb, line 7
def set_callback_internal(proc_entry, addr_entry, argc, ty, &cbp)
  if( argc < 0 )
    raise(ArgumentError, "arity should not be less than 0.")
  end
  addr = nil
  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
    }
  }
  addr
end
            
set_cdecl_callback(ty, argc, &cbp) click to toggle source
 
               # File dl/lib/dl/callback.rb, line 26
def set_cdecl_callback(ty, argc, &cbp)
  set_callback_internal(CdeclCallbackProcs, CdeclCallbackAddrs, argc, ty, &cbp)
end
            
Also aliased as: set_callback
set_stdcall_callback(ty, argc, &cbp) click to toggle source
 
               # File dl/lib/dl/callback.rb, line 30
def set_stdcall_callback(ty, argc, &cbp)
  set_callback_internal(StdcallCallbackProcs, StdcallCallbackAddrs, argc, ty, &cbp)
end