[前][次][番号順一覧][スレッド一覧]

ruby-changes:26154

From: ngoto <ko1@a...>
Date: Wed, 5 Dec 2012 22:24:30 +0900 (JST)
Subject: [ruby-changes:26154] ngoto:r38211 (trunk): * ext/dl/lib/dl/func.rb (DL::Function#bind): When Fiddle is used,

ngoto	2012-12-05 22:24:19 +0900 (Wed, 05 Dec 2012)

  New Revision: 38211

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38211

  Log:
    * ext/dl/lib/dl/func.rb (DL::Function#bind): When Fiddle is used,
      @ptr should be updated. This fixes SEGV raised in DL::Function#call
      after calling DL::Function#bind. [Bug #7516] [ruby-dev:46708]
    * test/dl/test_func.rb (test_bind): test for the above

  Modified files:
    trunk/ChangeLog
    trunk/ext/dl/lib/dl/func.rb
    trunk/test/dl/test_func.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38210)
+++ ChangeLog	(revision 38211)
@@ -1,3 +1,11 @@
+Wed Dec  5 22:13:57 2012  Naohisa Goto  <ngotogenome@g...>
+
+	* ext/dl/lib/dl/func.rb (DL::Function#bind): When Fiddle is used,
+	  @ptr should be updated. This fixes SEGV raised in DL::Function#call
+	  after calling DL::Function#bind. [Bug #7516] [ruby-dev:46708]
+
+	* test/dl/test_func.rb (test_bind): test for the above
+
 Wed Dec  5 18:53:00 2012  Masaya Tarui  <tarui@r...>
 
 	* thread.c (rb_thread_s_async_interrupt_timing): have to check ints
Index: ext/dl/lib/dl/func.rb
===================================================================
--- ext/dl/lib/dl/func.rb	(revision 38210)
+++ ext/dl/lib/dl/func.rb	(revision 38211)
@@ -118,6 +118,8 @@
             @block.call(*args)
           end
         }.new(@cfunc.ctype, @args, abi, name, block)
+        @ptr = @cfunc
+        return nil
       else
         if( !block )
           raise(RuntimeError, "block must be given.")
Index: test/dl/test_func.rb
===================================================================
--- test/dl/test_func.rb	(revision 38210)
+++ test/dl/test_func.rb	(revision 38211)
@@ -15,6 +15,14 @@
       assert_equal('<callback>qsort', cb.name)
     end
 
+    def test_bind
+      f = Function.new(CFunc.new(0, TYPE_INT, 'test'), [TYPE_INT, TYPE_INT])
+      assert_nothing_raised {
+        f.bind { |x, y| x + y }
+      }
+      assert_equal 579, f.call(123, 456)
+    end
+
     def test_to_i
       cfunc = CFunc.new(@libc['strcpy'], TYPE_VOIDP, 'strcpy')
       f = Function.new(cfunc, [TYPE_VOIDP, TYPE_VOIDP])

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]