1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2012-12-21 14:12:57 +00:00
parent 3fed8bc9a5
commit e852838cee
3 changed files with 20 additions and 1 deletions

View file

@ -1,3 +1,11 @@
Fri Dec 21 23:12:05 2012 Kouhei Sutou <kou@cozmixng.org>
* 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@cozmixng.org>
* ext/fiddle/lib/fiddle/import.rb (Fiddle::Importer#sizeof):

View file

@ -165,7 +165,7 @@ module Fiddle
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])

View file

@ -50,5 +50,16 @@ module Fiddle
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