summaryrefslogtreecommitdiff
path: root/ext/dl/lib/dl
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-30 23:41:07 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-30 23:41:07 +0000
commit0381ab07694668c4420307a6d8e9f0265ed9c56d (patch)
tree55f43cec08aa17fd93ff3d931a3b61ea680e66bb /ext/dl/lib/dl
parentf1cb6ea08f8fc897d914fc7c2c23701471657e4f (diff)
* ext/dl/lib/dl/struct.rb (DL::CUnionEntity#set_ctypes): Refactored
#set_types to reuse DL::CUnionEntity::size * test/dl/test_c_union_entity.rb: Added test Reviewed by Aaron Paterson git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/lib/dl')
-rw-r--r--ext/dl/lib/dl/struct.rb15
1 files changed, 2 insertions, 13 deletions
diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb
index 23f28bbaa3..628adb21c2 100644
--- a/ext/dl/lib/dl/struct.rb
+++ b/ext/dl/lib/dl/struct.rb
@@ -242,19 +242,8 @@ module DL
# Given +types+, calculate the necessary offset and for each union member
def set_ctypes(types)
@ctypes = types
- @offset = []
- @size = 0
- types.each_with_index{|t,i|
- @offset[i] = 0
- if( t.is_a?(Array) )
- size = SIZE_MAP[t[0]] * t[1]
- else
- size = SIZE_MAP[t]
- end
- if( size > @size )
- @size = size
- end
- }
+ @offset = Array.new(types.length, 0)
+ @size = self.class.size types
end
end
end