From 8346f7b2ad3138bdc30c8b39c8de13f3b392c059 Mon Sep 17 00:00:00 2001 From: kou Date: Fri, 21 Dec 2012 14:16:02 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/fiddle/lib/fiddle/struct.rb | 2 +- test/fiddle/test_c_struct_entry.rb | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3d7009d5bf..4c79830f5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Dec 21 23:15:25 2012 Kouhei Sutou + + * 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 * ext/fiddle/lib/fiddle/struct.rb (Fiddle::CStructEntity#set_ctypes): diff --git a/ext/fiddle/lib/fiddle/struct.rb b/ext/fiddle/lib/fiddle/struct.rb index ef53522592..695a4d2247 100644 --- a/ext/fiddle/lib/fiddle/struct.rb +++ b/ext/fiddle/lib/fiddle/struct.rb @@ -168,7 +168,7 @@ module Fiddle 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 diff --git a/test/fiddle/test_c_struct_entry.rb b/test/fiddle/test_c_struct_entry.rb index 3a5faefabc..a6cee75eb9 100644 --- a/test/fiddle/test_c_struct_entry.rb +++ b/test/fiddle/test_c_struct_entry.rb @@ -61,5 +61,14 @@ module Fiddle 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