Class: DL::CUnionEntity
- Inherits:
-
CStructEntity
- Object
- CPtr
- CStructEntity
- DL::CUnionEntity
- Includes:
- PackInfo
- Defined in:
- lib/dl/struct.rb
Constant Summary
Constants included from PackInfo
PackInfo::ALIGN_MAP, PackInfo::PACK_MAP, PackInfo::SIZE_MAP
Class Method Summary collapse
Instance Method Summary collapse
Methods included from PackInfo
Methods inherited from CStructEntity
#[], #[]=, #assign_names, #initialize, #to_s
Methods included from ValueUtil
#signed_value, #unsigned_value, #wrap_arg, #wrap_args
Methods inherited from CPtr
#+, #+@, #-, #-@, #<=>, #==, [], #[], #[]=, #eql?, #free, #free=, #initialize, #inspect, #null?, #ptr, #ref, #size, #size=, #to_i, #to_int, to_ptr, #to_s, #to_str, #to_value
Constructor Details
This class inherits a constructor from DL::CStructEntity
Class Method Details
.malloc(types, func = nil) ⇒ Object
175 176 177 178 |
# File 'lib/dl/struct.rb', line 175 def CUnionEntity.malloc(types, func=nil) addr = DL.malloc(CUnionEntity.size(types)) CUnionEntity.new(addr, types, func) end |
.size(types) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/dl/struct.rb', line 180 def CUnionEntity.size(types) size = 0 types.each_with_index{|t,i| if( t.is_a?(Array) ) tsize = PackInfo::SIZE_MAP[t[0]] * t[1] else tsize = PackInfo::SIZE_MAP[t] end if( tsize > size ) size = tsize end } end |
Instance Method Details
#set_ctypes(types) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/dl/struct.rb', line 194 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 } end |