Ruby  2.0.0p353(2013-11-22revision43784)
Data Structures | Macros | Typedefs | Functions | Variables
pointer.c File Reference
#include <ruby/ruby.h>
#include <ruby/io.h>
#include <ctype.h>
#include <fiddle.h>
Include dependency graph for pointer.c:

Go to the source code of this file.

Data Structures

struct  ptr_data
 

Macros

#define RPTR_DATA(obj)   ((struct ptr_data *)(DATA_PTR(obj)))
 

Typedefs

typedef void(* freefunc_t) (void *)
 

Functions

static freefunc_t get_freefunc (VALUE func, volatile VALUE *wrap)
 
static void fiddle_ptr_mark (void *ptr)
 
static void fiddle_ptr_free (void *ptr)
 
static size_t fiddle_ptr_memsize (const void *ptr)
 
static VALUE rb_fiddle_ptr_new2 (VALUE klass, void *ptr, long size, freefunc_t func)
 
static VALUE rb_fiddle_ptr_new (void *ptr, long size, freefunc_t func)
 
static VALUE rb_fiddle_ptr_malloc (long size, freefunc_t func)
 
static void * rb_fiddle_ptr2cptr (VALUE val)
 
static VALUE rb_fiddle_ptr_s_allocate (VALUE klass)
 
static VALUE rb_fiddle_ptr_initialize (int argc, VALUE argv[], VALUE self)
 
static VALUE rb_fiddle_ptr_s_malloc (int argc, VALUE argv[], VALUE klass)
 
static VALUE rb_fiddle_ptr_to_i (VALUE self)
 
static VALUE rb_fiddle_ptr_to_value (VALUE self)
 
static VALUE rb_fiddle_ptr_ptr (VALUE self)
 
static VALUE rb_fiddle_ptr_ref (VALUE self)
 
static VALUE rb_fiddle_ptr_null_p (VALUE self)
 
static VALUE rb_fiddle_ptr_free_set (VALUE self, VALUE val)
 
static VALUE rb_fiddle_ptr_free_get (VALUE self)
 
static VALUE rb_fiddle_ptr_to_s (int argc, VALUE argv[], VALUE self)
 
static VALUE rb_fiddle_ptr_to_str (int argc, VALUE argv[], VALUE self)
 
static VALUE rb_fiddle_ptr_inspect (VALUE self)
 
static VALUE rb_fiddle_ptr_eql (VALUE self, VALUE other)
 
static VALUE rb_fiddle_ptr_cmp (VALUE self, VALUE other)
 
static VALUE rb_fiddle_ptr_plus (VALUE self, VALUE other)
 
static VALUE rb_fiddle_ptr_minus (VALUE self, VALUE other)
 
static VALUE rb_fiddle_ptr_aref (int argc, VALUE argv[], VALUE self)
 
static VALUE rb_fiddle_ptr_aset (int argc, VALUE argv[], VALUE self)
 
static VALUE rb_fiddle_ptr_size_set (VALUE self, VALUE size)
 
static VALUE rb_fiddle_ptr_size_get (VALUE self)
 
static VALUE rb_fiddle_ptr_s_to_ptr (VALUE self, VALUE val)
 
void Init_fiddle_pointer (void)
 

Variables

VALUE rb_cPointer
 
static ID id_to_ptr
 
static const rb_data_type_t fiddle_ptr_data_type
 

Macro Definition Documentation

#define RPTR_DATA (   obj)    ((struct ptr_data *)(DATA_PTR(obj)))

Typedef Documentation

typedef void(* freefunc_t) (void *)

Definition at line 12 of file pointer.c.

Function Documentation

static void fiddle_ptr_free ( void *  ptr)
static

Definition at line 51 of file pointer.c.

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

static void fiddle_ptr_mark ( void *  ptr)
static

Definition at line 39 of file pointer.c.

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

static size_t fiddle_ptr_memsize ( const void *  ptr)
static

Definition at line 62 of file pointer.c.

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

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

Definition at line 24 of file pointer.c.

References func, NIL_P, NULL, NUM2PTR, and rb_Integer().

Referenced by rb_fiddle_ptr_free_set(), rb_fiddle_ptr_initialize(), and rb_fiddle_ptr_s_malloc().

void Init_fiddle_pointer ( void  )
static void* rb_fiddle_ptr2cptr ( VALUE  val)
static
static VALUE rb_fiddle_ptr_aref ( int  argc,
VALUE  argv[],
VALUE  self 
)
static
static VALUE rb_fiddle_ptr_aset ( int  argc,
VALUE  argv[],
VALUE  self 
)
static
static VALUE rb_fiddle_ptr_cmp ( VALUE  self,
VALUE  other 
)
static
static VALUE rb_fiddle_ptr_eql ( VALUE  self,
VALUE  other 
)
static

Definition at line 450 of file pointer.c.

References Qfalse, Qtrue, rb_cPointer, rb_fiddle_ptr2cptr(), and rb_obj_is_kind_of().

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_free_get ( VALUE  self)
static
static VALUE rb_fiddle_ptr_free_set ( VALUE  self,
VALUE  val 
)
static

Definition at line 307 of file pointer.c.

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

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_initialize ( int  argc,
VALUE  argv[],
VALUE  self 
)
static
static VALUE rb_fiddle_ptr_inspect ( VALUE  self)
static
static VALUE rb_fiddle_ptr_malloc ( long  size,
freefunc_t  func 
)
static

Definition at line 96 of file pointer.c.

References ptr_data::ptr, rb_fiddle_ptr_new(), rb_secure(), and ruby_xmalloc().

Referenced by rb_fiddle_ptr_s_malloc().

static VALUE rb_fiddle_ptr_minus ( VALUE  self,
VALUE  other 
)
static

Definition at line 510 of file pointer.c.

References NUM2LONG, ptr_data::ptr, rb_fiddle_ptr2cptr(), rb_fiddle_ptr_new(), RPTR_DATA, and size.

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_new ( void *  ptr,
long  size,
freefunc_t  func 
)
static
static VALUE rb_fiddle_ptr_new2 ( VALUE  klass,
void *  ptr,
long  size,
freefunc_t  func 
)
static
static VALUE rb_fiddle_ptr_null_p ( VALUE  self)
static

Definition at line 292 of file pointer.c.

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

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_plus ( VALUE  self,
VALUE  other 
)
static

Definition at line 492 of file pointer.c.

References NUM2LONG, ptr_data::ptr, rb_fiddle_ptr2cptr(), rb_fiddle_ptr_new(), RPTR_DATA, and size.

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_ptr ( VALUE  self)
static

Definition at line 261 of file pointer.c.

References ptr_data::ptr, rb_fiddle_ptr_new(), and TypedData_Get_Struct.

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_ref ( VALUE  self)
static

Definition at line 278 of file pointer.c.

References ptr_data::ptr, rb_fiddle_ptr_new(), and TypedData_Get_Struct.

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_s_allocate ( VALUE  klass)
static

Definition at line 127 of file pointer.c.

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

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_s_malloc ( int  argc,
VALUE  argv[],
VALUE  klass 
)
static
static VALUE rb_fiddle_ptr_s_to_ptr ( VALUE  self,
VALUE  val 
)
static
static VALUE rb_fiddle_ptr_size_get ( VALUE  self)
static

Definition at line 624 of file pointer.c.

References LONG2NUM, RPTR_DATA, and size.

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_size_set ( VALUE  self,
VALUE  size 
)
static

Definition at line 612 of file pointer.c.

References NUM2LONG, RPTR_DATA, and size.

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_to_i ( VALUE  self)
static

Definition at line 231 of file pointer.c.

References ptr_data::ptr, PTR2NUM, and TypedData_Get_Struct.

Referenced by Init_fiddle_pointer().

static VALUE rb_fiddle_ptr_to_s ( int  argc,
VALUE  argv[],
VALUE  self 
)
static
static VALUE rb_fiddle_ptr_to_str ( int  argc,
VALUE  argv[],
VALUE  self 
)
static
static VALUE rb_fiddle_ptr_to_value ( VALUE  self)
static

Definition at line 245 of file pointer.c.

References ptr_data::ptr, and TypedData_Get_Struct.

Referenced by Init_fiddle_pointer().

Variable Documentation

const rb_data_type_t fiddle_ptr_data_type
static
Initial value:
= {
"fiddle/pointer",
}
static void fiddle_ptr_mark(void *ptr)
Definition: pointer.c:39
static size_t fiddle_ptr_memsize(const void *ptr)
Definition: pointer.c:62
static void fiddle_ptr_free(void *ptr)
Definition: pointer.c:51

Definition at line 68 of file pointer.c.

ID id_to_ptr
static

Definition at line 36 of file pointer.c.

Referenced by Init_fiddle_pointer(), and rb_fiddle_ptr_s_to_ptr().

VALUE rb_cPointer