Ruby  1.9.3p551(2014-11-13revision48407)
Macros | Functions | Variables
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.

Macros

#define PRIsVALUE   "s"
 
#define RB_OBJ_CLASSNAME(obj)   rb_obj_classname(obj)
 
#define RB_OBJ_STRING(obj)   StringValueCStr(obj)
 

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)
 
void dlptr_init (VALUE val)
 
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
 

Macro Definition Documentation

◆ PRIsVALUE

#define PRIsVALUE   "s"

Definition at line 14 of file cptr.c.

Referenced by rb_dlptr_inspect().

◆ RB_OBJ_CLASSNAME

#define RB_OBJ_CLASSNAME (   obj)    rb_obj_classname(obj)

Definition at line 15 of file cptr.c.

Referenced by rb_dlptr_inspect().

◆ RB_OBJ_STRING

#define RB_OBJ_STRING (   obj)    StringValueCStr(obj)

Definition at line 16 of file cptr.c.

Function Documentation

◆ dlptr_free()

static void dlptr_free ( void *  ptr)
static

Definition at line 53 of file cptr.c.

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

◆ dlptr_init()

void dlptr_init ( VALUE  val)

Definition at line 76 of file cptr.c.

References dlptr_data_type, OBJ_TAINT, and TypedData_Get_Struct.

Referenced by rb_dlptr_new2().

◆ dlptr_mark()

static void dlptr_mark ( void *  ptr)
static

Definition at line 41 of file cptr.c.

References ptr_data::ptr, rb_gc_mark(), and ptr_data::wrap.

◆ dlptr_memsize()

static size_t dlptr_memsize ( const void *  ptr)
static

Definition at line 64 of file cptr.c.

References ptr_data::ptr, and ptr_data::size.

◆ get_freefunc()

static freefunc_t get_freefunc ( VALUE  func,
volatile VALUE wrap 
)
inlinestatic

◆ Init_dlptr()

void Init_dlptr ( void  )

◆ rb_dlptr2cptr()

void* rb_dlptr2cptr ( VALUE  val)

◆ rb_dlptr_aref()

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

◆ rb_dlptr_aset()

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

◆ rb_dlptr_cmp()

static VALUE rb_dlptr_cmp ( VALUE  self,
VALUE  other 
)
static

Definition at line 447 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().

◆ rb_dlptr_eql()

VALUE rb_dlptr_eql ( VALUE  self,
VALUE  other 
)

Definition at line 427 of file cptr.c.

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

Referenced by Init_dlptr().

◆ rb_dlptr_free_get()

static VALUE rb_dlptr_free_get ( VALUE  self)
static

Definition at line 327 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().

◆ rb_dlptr_free_set()

static VALUE rb_dlptr_free_set ( VALUE  self,
VALUE  val 
)
static

Definition at line 311 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().

◆ rb_dlptr_initialize()

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

◆ rb_dlptr_inspect()

static VALUE rb_dlptr_inspect ( VALUE  self)
static

◆ rb_dlptr_malloc()

VALUE rb_dlptr_malloc ( long  size,
freefunc_t  func 
)

Definition at line 107 of file cptr.c.

References func, ptr_data::ptr, rb_dlptr_new(), rb_secure(), ruby_xmalloc(), and size.

Referenced by rb_dlptr_s_malloc().

◆ rb_dlptr_minus()

static VALUE rb_dlptr_minus ( VALUE  self,
VALUE  other 
)
static

Definition at line 486 of file cptr.c.

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

Referenced by Init_dlptr().

◆ rb_dlptr_new()

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

◆ rb_dlptr_new2()

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

◆ rb_dlptr_null_p()

VALUE rb_dlptr_null_p ( VALUE  self)

Definition at line 297 of file cptr.c.

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

Referenced by Init_dlptr().

◆ rb_dlptr_plus()

static VALUE rb_dlptr_plus ( VALUE  self,
VALUE  other 
)
static

Definition at line 468 of file cptr.c.

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

Referenced by Init_dlptr().

◆ rb_dlptr_ptr()

VALUE rb_dlptr_ptr ( VALUE  self)

Definition at line 268 of file cptr.c.

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

Referenced by Init_dlptr().

◆ rb_dlptr_ref()

VALUE rb_dlptr_ref ( VALUE  self)

Definition at line 283 of file cptr.c.

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

Referenced by Init_dlptr().

◆ rb_dlptr_s_allocate()

static VALUE rb_dlptr_s_allocate ( VALUE  klass)
static

Definition at line 138 of file cptr.c.

References dlptr_data_type, ptr_data::free, ptr_data::ptr, rb_secure(), ptr_data::size, and TypedData_Make_Struct.

Referenced by Init_dlptr().

◆ rb_dlptr_s_malloc()

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

Definition at line 209 of file cptr.c.

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

Referenced by Init_dlptr().

◆ rb_dlptr_s_to_ptr()

static VALUE rb_dlptr_s_to_ptr ( VALUE  self,
VALUE  val 
)
static

◆ rb_dlptr_size_get()

static VALUE rb_dlptr_size_get ( VALUE  self)
static

Definition at line 597 of file cptr.c.

References LONG2NUM, RPTR_DATA, and size.

Referenced by Init_dlptr().

◆ rb_dlptr_size_set()

static VALUE rb_dlptr_size_set ( VALUE  self,
VALUE  size 
)
static

Definition at line 585 of file cptr.c.

References NUM2LONG(), RPTR_DATA, and size.

Referenced by Init_dlptr().

◆ rb_dlptr_to_i()

static VALUE rb_dlptr_to_i ( VALUE  self)
static

Definition at line 240 of file cptr.c.

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

Referenced by Init_dlptr().

◆ rb_dlptr_to_s()

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

◆ rb_dlptr_to_str()

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

◆ rb_dlptr_to_value()

static VALUE rb_dlptr_to_value ( VALUE  self)
static

Definition at line 254 of file cptr.c.

References dlptr_data_type, ptr_data::ptr, and TypedData_Get_Struct.

Referenced by Init_dlptr().

Variable Documentation

◆ dlptr_data_type

const rb_data_type_t dlptr_data_type
static
Initial value:
= {
"dl/ptr",
}
static void dlptr_free(void *ptr)
Definition: cptr.c:53
static void dlptr_mark(void *ptr)
Definition: cptr.c:41
static size_t dlptr_memsize(const void *ptr)
Definition: cptr.c:64

Definition at line 70 of file cptr.c.

Referenced by dlptr_init(), 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_to_ptr

ID id_to_ptr
static

Definition at line 38 of file cptr.c.

Referenced by Init_dlptr(), and rb_dlptr_s_to_ptr().

◆ rb_cDLCPtr

VALUE rb_cDLCPtr