class Fiddle::CUnionEntity
一个指向 C 联合体的指针
公共类方法
size(types) 点击以切换源代码
返回给定 types
的联合体所需的大小。
Fiddle::CUnionEntity.size( [ Fiddle::TYPE_DOUBLE, Fiddle::TYPE_INT, Fiddle::TYPE_CHAR, Fiddle::TYPE_VOIDP ]) #=> 8
# File fiddle/lib/fiddle/struct.rb, line 542 def CUnionEntity.size(types) types.map { |type, count = 1| if type.respond_to?(:entity_class) type.size * count else PackInfo::SIZE_MAP[type] * count end }.max end
公共实例方法
set_ctypes(types) 点击以切换源代码
计算必要的偏移量,并为每个具有给定 types
的联合体成员计算
# File fiddle/lib/fiddle/struct.rb, line 554 def set_ctypes(types) @ctypes = types @offset = Array.new(types.length, 0) @size = self.class.size types end