ruby-changes:13810
From: tenderlove <ko1@a...>
Date: Sun, 1 Nov 2009 10:47:20 +0900 (JST)
Subject: [ruby-changes:13810] Ruby:r25608 (trunk): * ext/dl/cptr.c (rb_dlptr_ptr, rb_dlptr_ref) adding documentation
tenderlove 2009-11-01 10:47:08 +0900 (Sun, 01 Nov 2009) New Revision: 25608 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25608 Log: * ext/dl/cptr.c (rb_dlptr_ptr, rb_dlptr_ref) adding documentation * test/dl/test_cptr.rb (test_ref_ptr) testing CPtr#ref and CPtr#ptr Modified files: trunk/ext/dl/cptr.c trunk/test/dl/test_cptr.rb Index: ext/dl/cptr.c =================================================================== --- ext/dl/cptr.c (revision 25607) +++ ext/dl/cptr.c (revision 25608) @@ -210,6 +210,12 @@ return (VALUE)(data->ptr); } +/* + * call-seq: ptr + * + * Returns a DL::CPtr that is a dereferenced pointer for this DL::CPtr. + * Analogous to the star operator in C. + */ VALUE rb_dlptr_ptr(VALUE self) { @@ -219,6 +225,12 @@ return rb_dlptr_new(*((void**)(data->ptr)),0,0); } +/* + * call-seq: ref + * + * Returns a DL::CPtr that is a reference pointer for this DL::CPtr. + * Analogous to the ampersand operator in C. + */ VALUE rb_dlptr_ref(VALUE self) { Index: test/dl/test_cptr.rb =================================================================== --- test/dl/test_cptr.rb (revision 25607) +++ test/dl/test_cptr.rb (revision 25608) @@ -3,6 +3,14 @@ module DL class TestCPtr < TestBase + def test_ref_ptr + ary = [0,1,2,4,5] + addr = CPtr.new(dlwrap(ary)) + assert_equal addr.to_i, addr.ref.ptr.to_i + + assert_equal addr.to_i, (+ (- addr)).to_i + end + def test_to_value ary = [0,1,2,4,5] addr = CPtr.new(dlwrap(ary)) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/