From 6a1aebaabf9653e2178e8d887632c4c5802189d8 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Fri, 4 Dec 2009 23:21:01 +0000 Subject: [PATCH] * ext/dl/cptr.c (to_int): DL::CPtr supports to_int git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/dl/cptr.c | 1 + test/dl/test_cptr.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c index b1b156a2b2..11ecf6f81d 100644 --- a/ext/dl/cptr.c +++ b/ext/dl/cptr.c @@ -626,6 +626,7 @@ Init_dlptr(void) rb_define_method(rb_cDLCPtr, "free=", rb_dlptr_free_set, 1); rb_define_method(rb_cDLCPtr, "free", rb_dlptr_free_get, 0); rb_define_method(rb_cDLCPtr, "to_i", rb_dlptr_to_i, 0); + rb_define_method(rb_cDLCPtr, "to_int", rb_dlptr_to_i, 0); rb_define_method(rb_cDLCPtr, "to_value", rb_dlptr_to_value, 0); rb_define_method(rb_cDLCPtr, "ptr", rb_dlptr_ptr, 0); rb_define_method(rb_cDLCPtr, "+@", rb_dlptr_ptr, 0); diff --git a/test/dl/test_cptr.rb b/test/dl/test_cptr.rb index 64b78d134f..953af286e1 100644 --- a/test/dl/test_cptr.rb +++ b/test/dl/test_cptr.rb @@ -3,6 +3,11 @@ require_relative '../ruby/envutil' module DL class TestCPtr < TestBase + def test_cptr_to_int + null = DL::NULL + assert_equal(null.to_i, null.to_int) + end + def test_malloc_free_func_int free = CFunc.new(DL::RUBY_FREE, TYPE_VOID, 'free')