A
Alex Fenton
Hi
I want to create a ruby method in a C++ extension that will spit out the
C++ pointer address of the wrapped object - useful for debugging. I
have got the following, which works, but I was wondering if there was an
easier way to access this that I'm missing?
static VALUE
cpp_ptr_addr(VALUE self, VALUE obj)
{
size_t ptr = (size_t)DATA_PTR(obj);
return rb_funcall( rb_mKernel, rb_intern("sprintf"), 2,
rb_str_new2("0x%x"), OFFT2NUM(ptr) );
}
thanks
alex
I want to create a ruby method in a C++ extension that will spit out the
C++ pointer address of the wrapped object - useful for debugging. I
have got the following, which works, but I was wondering if there was an
easier way to access this that I'm missing?
static VALUE
cpp_ptr_addr(VALUE self, VALUE obj)
{
size_t ptr = (size_t)DATA_PTR(obj);
return rb_funcall( rb_mKernel, rb_intern("sprintf"), 2,
rb_str_new2("0x%x"), OFFT2NUM(ptr) );
}
thanks
alex