ext/dl/cptr.c File Reference

#include <ruby/ruby.h>
#include <ruby/io.h>
#include <ctype.h>
#include "dl.h"

Go to the source code of this file.

Functions

static freefunc_t get_freefunc (VALUE func, volatile VALUE *wrap)
static void dlptr_mark (void *ptr)
static void dlptr_free (void *ptr)
static size_t dlptr_memsize (const void *ptr)
VALUE rb_dlptr_new2 (VALUE klass, void *ptr, long size, freefunc_t func)
VALUE rb_dlptr_new (void *ptr, long size, freefunc_t func)
VALUE rb_dlptr_malloc (long size, freefunc_t func)
void * rb_dlptr2cptr (VALUE val)
static VALUE rb_dlptr_s_allocate (VALUE klass)
static VALUE rb_dlptr_initialize (int argc, VALUE argv[], VALUE self)
static VALUE rb_dlptr_s_malloc (int argc, VALUE argv[], VALUE klass)
static VALUE rb_dlptr_to_i (VALUE self)
static VALUE rb_dlptr_to_value (VALUE self)
VALUE rb_dlptr_ptr (VALUE self)
VALUE rb_dlptr_ref (VALUE self)
VALUE rb_dlptr_null_p (VALUE self)
static VALUE rb_dlptr_free_set (VALUE self, VALUE val)
static VALUE rb_dlptr_free_get (VALUE self)
static VALUE rb_dlptr_to_s (int argc, VALUE argv[], VALUE self)
static VALUE rb_dlptr_to_str (int argc, VALUE argv[], VALUE self)
static VALUE rb_dlptr_inspect (VALUE self)
VALUE rb_dlptr_eql (VALUE self, VALUE other)
static VALUE rb_dlptr_cmp (VALUE self, VALUE other)
static VALUE rb_dlptr_plus (VALUE self, VALUE other)
static VALUE rb_dlptr_minus (VALUE self, VALUE other)
VALUE rb_dlptr_aref (int argc, VALUE argv[], VALUE self)
VALUE rb_dlptr_aset (int argc, VALUE argv[], VALUE self)
static VALUE rb_dlptr_size_set (VALUE self, VALUE size)
static VALUE rb_dlptr_size_get (VALUE self)
static VALUE rb_dlptr_s_to_ptr (VALUE self, VALUE val)
void Init_dlptr (void)

Variables

VALUE rb_cDLCPtr
static ID id_to_ptr
static const rb_data_type_t dlptr_data_type


Function Documentation

static void dlptr_free ( void *  ptr  )  [static]

Definition at line 44 of file cptr.c.

References ptr_data::free, ptr_data::ptr, and xfree.

static void dlptr_mark ( void *  ptr  )  [static]

Definition at line 32 of file cptr.c.

References rb_gc_mark(), and ptr_data::wrap.

static size_t dlptr_memsize ( const void *  ptr  )  [static]

Definition at line 56 of file cptr.c.

References ptr_data::size.

static freefunc_t get_freefunc ( VALUE  func,
volatile VALUE *  wrap 
) [inline, static]

Definition at line 13 of file cptr.c.

References NIL_P, NULL, NUM2PTR, rb_dlcfunc_kind_p(), rb_Integer(), RCFUNC_DATA, and VALUE.

Referenced by rb_dlptr_free_set(), rb_dlptr_initialize(), rb_dlptr_s_malloc(), rb_fiddle_ptr_free_set(), rb_fiddle_ptr_initialize(), and rb_fiddle_ptr_s_malloc().

void Init_dlptr ( void   ) 

Definition at line 626 of file cptr.c.

References id_to_ptr, rb_cDLCPtr, rb_cObject, rb_define_alloc_func(), rb_define_class_under(), rb_define_const(), rb_define_method(), rb_define_singleton_method(), rb_dlptr_aref(), rb_dlptr_aset(), rb_dlptr_cmp(), rb_dlptr_eql(), rb_dlptr_free_get(), rb_dlptr_free_set(), rb_dlptr_initialize(), rb_dlptr_inspect(), rb_dlptr_minus(), rb_dlptr_new(), rb_dlptr_null_p(), rb_dlptr_plus(), rb_dlptr_ptr(), rb_dlptr_ref(), rb_dlptr_s_allocate(), rb_dlptr_s_malloc(), rb_dlptr_s_to_ptr(), rb_dlptr_size_get(), rb_dlptr_size_set(), rb_dlptr_to_i(), rb_dlptr_to_s(), rb_dlptr_to_str(), rb_dlptr_to_value(), rb_intern, and rb_mDL.

Referenced by Init_dl().

void* rb_dlptr2cptr ( VALUE  val  ) 

Definition at line 99 of file cptr.c.

References dlptr_data_type, NULL, ptr_data::ptr, Qnil, rb_cDLCPtr, rb_eTypeError, rb_obj_is_kind_of(), rb_raise(), and TypedData_Get_Struct.

Referenced by rb_dlptr_aset(), rb_dlptr_cmp(), rb_dlptr_eql(), rb_dlptr_minus(), and rb_dlptr_plus().

VALUE rb_dlptr_aref ( int  argc,
VALUE  argv[],
VALUE  self 
)

Definition at line 487 of file cptr.c.

References dlptr_data_type, INT2NUM, len, NUM2ULONG, ptr_data::ptr, Qnil, rb_bug(), rb_eDLError, rb_raise(), rb_scan_args(), rb_tainted_str_new(), TypedData_Get_Struct, and VALUE.

Referenced by Init_dlptr().

VALUE rb_dlptr_aset ( int  argc,
VALUE  argv[],
VALUE  self 
)

Definition at line 522 of file cptr.c.

References dlptr_data_type, len, NUM2PTR, NUM2UINT, NUM2ULONG, ptr_data::ptr, Qnil, rb_bug(), rb_cDLCPtr, rb_dlptr2cptr(), rb_eDLError, rb_obj_is_kind_of(), rb_raise(), rb_scan_args(), RB_TYPE_P, StringValuePtr, T_STRING, TypedData_Get_Struct, and VALUE.

Referenced by Init_dlptr().

static VALUE rb_dlptr_cmp ( VALUE  self,
VALUE  other 
) [static]

Definition at line 427 of file cptr.c.

References diff(), INT2FIX, INT2NUM, Qnil, rb_cDLCPtr, rb_dlptr2cptr(), rb_obj_is_kind_of(), and SIGNED_VALUE.

Referenced by Init_dlptr().

VALUE rb_dlptr_eql ( VALUE  self,
VALUE  other 
)

Definition at line 407 of file cptr.c.

References Qfalse, Qtrue, rb_cDLCPtr, rb_dlptr2cptr(), and rb_obj_is_kind_of().

Referenced by Init_dlptr().

static VALUE rb_dlptr_free_get ( VALUE  self  )  [static]

Definition at line 307 of file cptr.c.

References CFUNC_CDECL, dlptr_data_type, DLTYPE_VOID, ptr_data::free, rb_dlcfunc_new(), and TypedData_Get_Struct.

Referenced by Init_dlptr().

static VALUE rb_dlptr_free_set ( VALUE  self,
VALUE  val 
) [static]

Definition at line 291 of file cptr.c.

References dlptr_data_type, ptr_data::free, get_freefunc(), Qnil, TypedData_Get_Struct, and ptr_data::wrap.

Referenced by Init_dlptr().

static VALUE rb_dlptr_initialize ( int  argc,
VALUE  argv[],
VALUE  self 
) [static]

Definition at line 142 of file cptr.c.

References dlptr_data_type, f, ptr_data::free, get_freefunc(), NULL, NUM2LONG, NUM2PTR, ptr_data::ptr, Qnil, rb_Integer(), rb_scan_args(), ptr_data::size, size, sym, TypedData_Get_Struct, VALUE, and ptr_data::wrap.

Referenced by Init_dlptr().

static VALUE rb_dlptr_inspect ( VALUE  self  )  [static]

Definition at line 389 of file cptr.c.

References dlptr_data_type, ptr_data::free, PRIsVALUE, ptr_data::ptr, rb_obj_class(), rb_sprintf(), ptr_data::size, and TypedData_Get_Struct.

Referenced by Init_dlptr().

VALUE rb_dlptr_malloc ( long  size,
freefunc_t  func 
)

Definition at line 89 of file cptr.c.

References ptr_data::ptr, rb_dlptr_new(), and ruby_xmalloc().

static VALUE rb_dlptr_minus ( VALUE  self,
VALUE  other 
) [static]

Definition at line 466 of file cptr.c.

References NUM2LONG, ptr_data::ptr, rb_dlptr2cptr(), rb_dlptr_new(), RPTR_DATA, and size.

Referenced by Init_dlptr().

VALUE rb_dlptr_new ( void *  ptr,
long  size,
freefunc_t  func 
)

Definition at line 83 of file cptr.c.

References rb_cDLCPtr, and rb_dlptr_new2().

VALUE rb_dlptr_new2 ( VALUE  klass,
void *  ptr,
long  size,
freefunc_t  func 
)

Definition at line 68 of file cptr.c.

References dlptr_data_type, ptr_data::free, OBJ_TAINT, ptr_data::ptr, ptr_data::size, TypedData_Make_Struct, val, and VALUE.

VALUE rb_dlptr_null_p ( VALUE  self  ) 

Definition at line 277 of file cptr.c.

References dlptr_data_type, ptr_data::ptr, Qfalse, Qtrue, and TypedData_Get_Struct.

Referenced by Init_dlptr().

static VALUE rb_dlptr_plus ( VALUE  self,
VALUE  other 
) [static]

Definition at line 448 of file cptr.c.

References NUM2LONG, ptr_data::ptr, rb_dlptr2cptr(), rb_dlptr_new(), RPTR_DATA, and size.

Referenced by Init_dlptr().

VALUE rb_dlptr_ptr ( VALUE  self  ) 

Definition at line 248 of file cptr.c.

References dlptr_data_type, ptr_data::ptr, rb_dlptr_new(), and TypedData_Get_Struct.

Referenced by Init_dlptr().

VALUE rb_dlptr_ref ( VALUE  self  ) 

Definition at line 263 of file cptr.c.

References dlptr_data_type, ptr_data::ptr, rb_dlptr_new(), and TypedData_Get_Struct.

Referenced by Init_dlptr().

static VALUE rb_dlptr_s_allocate ( VALUE  klass  )  [static]

Definition at line 119 of file cptr.c.

References dlptr_data_type, ptr_data::free, ptr_data::ptr, ptr_data::size, TypedData_Make_Struct, and VALUE.

Referenced by Init_dlptr().

static VALUE rb_dlptr_s_malloc ( int  argc,
VALUE  argv[],
VALUE  klass 
) [static]

Definition at line 189 of file cptr.c.

References f, get_freefunc(), NULL, NUM2LONG, rb_bug(), rb_dlptr_malloc(), rb_scan_args(), RPTR_DATA, size, sym, VALUE, and ptr_data::wrap.

Referenced by Init_dlptr().

static VALUE rb_dlptr_s_to_ptr ( VALUE  self,
VALUE  val 
) [static]

Definition at line 591 of file cptr.c.

References GetOpenFile, id_to_ptr, NULL, NUM2PTR, OBJ_INFECT, ptr_data::ptr, Qundef, rb_cDLCPtr, rb_check_funcall(), rb_cIO, rb_cString, rb_dlptr_new(), rb_eDLError, rb_Integer(), rb_io_stdio_file(), rb_obj_is_kind_of(), rb_raise(), RPTR_DATA, RSTRING_LEN, RTEST, StringValuePtr, VALUE, and ptr_data::wrap.

Referenced by Init_dlptr().

static VALUE rb_dlptr_size_get ( VALUE  self  )  [static]

Definition at line 577 of file cptr.c.

References LONG2NUM, RPTR_DATA, and size.

Referenced by Init_dlptr().

static VALUE rb_dlptr_size_set ( VALUE  self,
VALUE  size 
) [static]

Definition at line 565 of file cptr.c.

References NUM2LONG, and RPTR_DATA.

Referenced by Init_dlptr().

static VALUE rb_dlptr_to_i ( VALUE  self  )  [static]

Definition at line 220 of file cptr.c.

References dlptr_data_type, ptr_data::ptr, PTR2NUM, and TypedData_Get_Struct.

Referenced by Init_dlptr().

static VALUE rb_dlptr_to_s ( int  argc,
VALUE  argv[],
VALUE  self 
) [static]

Definition at line 327 of file cptr.c.

References dlptr_data_type, len, NUM2INT, ptr_data::ptr, rb_bug(), rb_scan_args(), rb_tainted_str_new(), rb_tainted_str_new2, TypedData_Get_Struct, val, and VALUE.

Referenced by Init_dlptr().

static VALUE rb_dlptr_to_str ( int  argc,
VALUE  argv[],
VALUE  self 
) [static]

Definition at line 360 of file cptr.c.

References dlptr_data_type, len, NUM2INT, ptr_data::ptr, rb_bug(), rb_scan_args(), rb_tainted_str_new(), ptr_data::size, TypedData_Get_Struct, val, and VALUE.

Referenced by Init_dlptr().

static VALUE rb_dlptr_to_value ( VALUE  self  )  [static]

Definition at line 234 of file cptr.c.

References dlptr_data_type, ptr_data::ptr, TypedData_Get_Struct, and VALUE.

Referenced by Init_dlptr().


Variable Documentation

const rb_data_type_t dlptr_data_type [static]

Initial value:

 {
    "dl/ptr",
    {dlptr_mark, dlptr_free, dlptr_memsize,},
}

Definition at line 62 of file cptr.c.

Referenced by rb_dlptr2cptr(), rb_dlptr_aref(), rb_dlptr_aset(), rb_dlptr_free_get(), rb_dlptr_free_set(), rb_dlptr_initialize(), rb_dlptr_inspect(), rb_dlptr_new2(), rb_dlptr_null_p(), rb_dlptr_ptr(), rb_dlptr_ref(), rb_dlptr_s_allocate(), rb_dlptr_to_i(), rb_dlptr_to_s(), rb_dlptr_to_str(), and rb_dlptr_to_value().

ID id_to_ptr [static]

Definition at line 29 of file cptr.c.

Referenced by Init_dlptr(), Init_fiddle_pointer(), rb_dlptr_s_to_ptr(), and rb_fiddle_ptr_s_to_ptr().

VALUE rb_cDLCPtr

Definition at line 10 of file cptr.c.

Referenced by Init_dlptr(), rb_dlptr2cptr(), rb_dlptr_aset(), rb_dlptr_cmp(), rb_dlptr_eql(), rb_dlptr_new(), and rb_dlptr_s_to_ptr().


Generated on 19 Jul 2016 for Ruby by  doxygen 1.4.7