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

ruby-changes:26486

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

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

  New Revision: 38537

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

  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_array):
      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 38536)
+++ ChangeLog	(revision 38537)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Dec 21 23:12:05 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_array):
+	  Added the test for the above.
+
 Fri Dec 21 22:43:36 2012  Kouhei Sutou  <kou@c...>
 
 	* ext/fiddle/lib/fiddle/import.rb (Fiddle::Importer#sizeof):
Index: ext/fiddle/lib/fiddle/struct.rb
===================================================================
--- ext/fiddle/lib/fiddle/struct.rb	(revision 38536)
+++ ext/fiddle/lib/fiddle/struct.rb	(revision 38537)
@@ -165,7 +165,7 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/lib/fiddle/struct.rb#L165
       when Array
         case ty[0]
         when TYPE_VOIDP
-          val = val.collect{|v| CPtr.new(v)}
+          val = val.collect{|v| Pointer.new(v)}
         end
       when TYPE_VOIDP
         val = CPtr.new(val[0])
Index: test/fiddle/test_c_struct_entry.rb
===================================================================
--- test/fiddle/test_c_struct_entry.rb	(revision 38536)
+++ test/fiddle/test_c_struct_entry.rb	(revision 38537)
@@ -50,5 +50,16 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_c_struct_entry.rb#L50
       assert_equal 1, union['long']
       assert_equal 2, union['int']
     end
+
+    def test_aref_pointer_array
+      team = CStructEntity.malloc([[TYPE_VOIDP, 2]])
+      team.assign_names(["names"])
+      alice = Fiddle::Pointer.malloc(6)
+      alice[0, 6] = "Alice\0"
+      bob = Fiddle::Pointer.malloc(4)
+      bob[0, 4] = "Bob\0"
+      team["names"] = [alice, bob]
+      assert_equal(["Alice", "Bob"], team["names"].map(&:to_s))
+    end
   end
 end

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

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