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

ruby-changes:26487

From: kou <ko1@a...>
Date: Fri, 21 Dec 2012 23:16:14 +0900 (JST)
Subject: [ruby-changes:26487] kou:r38538 (trunk): * ext/fiddle/lib/fiddle/struct.rb (Fiddle::CStructEntity#set_ctypes):

kou	2012-12-21 23:16:02 +0900 (Fri, 21 Dec 2012)

  New Revision: 38538

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

  Log:
    * ext/fiddle/lib/fiddle/struct.rb (Fiddle::CStructEntity#set_ctypes):
      CPtr -> Pointer.
    * test/fiddle/test_c_struct_entry.rb
      (Fiddle::TestCStructEntity#test_aref_pointer):
      Added the test for the above.

  Modified files:
    trunk/ChangeLog
    trunk/ext/fiddle/lib/fiddle/struct.rb
    trunk/test/fiddle/test_c_struct_entry.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38537)
+++ ChangeLog	(revision 38538)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Dec 21 23:15:25 2012  Kouhei Sutou  <kou@c...>
+
+	* ext/fiddle/lib/fiddle/struct.rb (Fiddle::CStructEntity#set_ctypes):
+	  CPtr -> Pointer.
+	* test/fiddle/test_c_struct_entry.rb
+	  (Fiddle::TestCStructEntity#test_aref_pointer):
+	  Added the test for the above.
+
 Fri Dec 21 23:12:05 2012  Kouhei Sutou  <kou@c...>
 
 	* ext/fiddle/lib/fiddle/struct.rb (Fiddle::CStructEntity#set_ctypes):
Index: ext/fiddle/lib/fiddle/struct.rb
===================================================================
--- ext/fiddle/lib/fiddle/struct.rb	(revision 38537)
+++ ext/fiddle/lib/fiddle/struct.rb	(revision 38538)
@@ -168,7 +168,7 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/lib/fiddle/struct.rb#L168
           val = val.collect{|v| Pointer.new(v)}
         end
       when TYPE_VOIDP
-        val = CPtr.new(val[0])
+        val = Pointer.new(val[0])
       else
         val = val[0]
       end
Index: test/fiddle/test_c_struct_entry.rb
===================================================================
--- test/fiddle/test_c_struct_entry.rb	(revision 38537)
+++ test/fiddle/test_c_struct_entry.rb	(revision 38538)
@@ -61,5 +61,14 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_c_struct_entry.rb#L61
       team["names"] = [alice, bob]
       assert_equal(["Alice", "Bob"], team["names"].map(&:to_s))
     end
+
+    def test_aref_pointer
+      user = CStructEntity.malloc([TYPE_VOIDP])
+      user.assign_names(["name"])
+      alice = Fiddle::Pointer.malloc(6)
+      alice[0, 6] = "Alice\0"
+      user["name"] = alice
+      assert_equal("Alice", user["name"].to_s)
+    end
   end
 end

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

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