21 #define RPTR_DATA(obj) ((struct ptr_data *)(DATA_PTR(obj)))
32 *wrap = (addrnum !=
func) ? func : 0;
65 return data ?
sizeof(*data) + data->
size : 0;
102 memset(ptr,0,(
size_t)size);
116 else if (val ==
Qnil) {
160 if (
rb_scan_args(argc, argv,
"12", &ptr, &size, &sym) >= 1) {
162 if (addrnum != ptr) wrap =
ptr;
179 data->
wrap[1] = funcwrap;
216 rb_bug(
"rb_fiddle_ptr_s_malloc");
379 rb_bug(
"rb_fiddle_ptr_to_s");
417 rb_bug(
"rb_fiddle_ptr_to_str");
436 snprintf(str, 1023,
"#<%s:%p ptr=%p size=%ld free=%p>",
544 retval =
INT2NUM(*((
char *)data->
ptr + offset));
552 rb_bug(
"rb_fiddle_ptr_aref()");
571 VALUE arg0, arg1, arg2;
579 switch(
rb_scan_args(argc, argv,
"21", &arg0, &arg1, &arg2) ){
597 memcpy((
char *)data->
ptr + offset, mem, len);
601 rb_bug(
"rb_fiddle_ptr_aset()");
664 if (num == val) wrap = 0;
RUBY_EXTERN VALUE rb_cString
static VALUE rb_fiddle_ptr_ref(VALUE self)
void rb_bug(const char *fmt,...)
static VALUE rb_fiddle_ptr_plus(VALUE self, VALUE other)
static VALUE rb_fiddle_ptr_inspect(VALUE self)
static VALUE rb_fiddle_ptr_to_s(int argc, VALUE argv[], VALUE self)
static VALUE rb_fiddle_ptr_eql(VALUE self, VALUE other)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
#define TypedData_Get_Struct(obj, type, data_type, sval)
static VALUE rb_fiddle_ptr_ptr(VALUE self)
VALUE rb_ary_push(VALUE ary, VALUE item)
static void * rb_fiddle_ptr2cptr(VALUE val)
SSL_METHOD *(* func)(void)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
void rb_raise(VALUE exc, const char *fmt,...)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
static VALUE rb_fiddle_ptr_s_malloc(int argc, VALUE argv[], VALUE klass)
VALUE rb_tainted_str_new2(const char *)
void rb_gc_mark(VALUE ptr)
#define GetOpenFile(obj, fp)
static VALUE rb_fiddle_ptr_cmp(VALUE self, VALUE other)
#define RB_TYPE_P(obj, type)
RUBY_EXTERN VALUE rb_cObject
static VALUE rb_fiddle_ptr_aref(int argc, VALUE argv[], VALUE self)
static VALUE rb_fiddle_ptr_aset(int argc, VALUE argv[], VALUE self)
void rb_define_const(VALUE, const char *, VALUE)
static VALUE rb_fiddle_ptr_new2(VALUE klass, void *ptr, long size, freefunc_t func)
static void fiddle_ptr_mark(void *ptr)
void(* freefunc_t)(void *)
VALUE rb_check_funcall(VALUE, ID, int, VALUE *)
static freefunc_t get_freefunc(VALUE func, volatile VALUE *wrap)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
const char * rb_class2name(VALUE)
static VALUE rb_fiddle_ptr_size_set(VALUE self, VALUE size)
static VALUE rb_fiddle_ptr_free_get(VALUE self)
void * ruby_xmalloc(size_t size)
static VALUE rb_fiddle_ptr_size_get(VALUE self)
VALUE rb_fiddle_new_function(VALUE address, VALUE arg_types, VALUE ret_type)
static VALUE rb_fiddle_ptr_malloc(long size, freefunc_t func)
static VALUE rb_fiddle_ptr_null_p(VALUE self)
static VALUE rb_fiddle_ptr_to_i(VALUE self)
static VALUE rb_fiddle_ptr_free_set(VALUE self, VALUE val)
static Bigint * diff(Bigint *a, Bigint *b)
#define TypedData_Make_Struct(klass, type, data_type, sval)
static VALUE rb_fiddle_ptr_to_value(VALUE self)
static VALUE rb_fiddle_ptr_new(void *ptr, long size, freefunc_t func)
static VALUE rb_fiddle_ptr_s_to_ptr(VALUE self, VALUE val)
FILE * rb_io_stdio_file(rb_io_t *fptr)
static const rb_data_type_t fiddle_ptr_data_type
#define StringValuePtr(v)
static VALUE rb_fiddle_ptr_initialize(int argc, VALUE argv[], VALUE self)
static VALUE rb_fiddle_ptr_s_allocate(VALUE klass)
void Init_fiddle_pointer(void)
static VALUE rb_fiddle_ptr_to_str(int argc, VALUE argv[], VALUE self)
VALUE rb_tainted_str_new(const char *, long)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_new2(const char *)
static size_t fiddle_ptr_memsize(const void *ptr)
static void fiddle_ptr_free(void *ptr)
static VALUE rb_fiddle_ptr_minus(VALUE self, VALUE other)