Class: Fiddle::CUnionEntity
- Inherits:
-
CStructEntity
- Object
- Pointer
- CStructEntity
- Fiddle::CUnionEntity
- Includes:
- PackInfo
- Defined in:
- lib/fiddle/struct.rb
Overview
A pointer to a C union
Constant Summary
Constants included from PackInfo
PackInfo::ALIGN_MAP, PackInfo::PACK_MAP, PackInfo::SIZE_MAP
Instance Attribute Summary
Attributes inherited from Pointer
Class Method Summary collapse
-
.size(types) ⇒ Object
Returns the size needed for the union with the given
types
.
Instance Method Summary collapse
-
#set_ctypes(types) ⇒ Object
Calculate the necessary offset and for each union member with the given
types
.
Methods included from PackInfo
Methods inherited from CStructEntity
#+, #-, #[], #[]=, alignment, #assign_names, #initialize, malloc, #to_s
Methods included from ValueUtil
#signed_value, #unsigned_value, #wrap_arg, #wrap_args
Methods inherited from Pointer
#+, #+@, #-, #-@, #<=>, #==, #[], [], #[]=, #call_free, #eql?, #free, #free=, #freed?, from_native, #initialize, #inspect, malloc, #null?, #ptr, read, #ref, #size, #size=, #to_i, to_native, #to_ptr, to_ptr, #to_s, #to_str, #to_value, write
Constructor Details
This class inherits a constructor from Fiddle::CStructEntity
Class Method Details
.size(types) ⇒ Object
542 543 544 545 546 547 548 549 550 |
# File '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 |
Instance Method Details
#set_ctypes(types) ⇒ Object
Calculate the necessary offset and for each union member with the given types
554 555 556 557 558 |
# File 'lib/fiddle/struct.rb', line 554 def set_ctypes(types) @ctypes = types @offset = Array.new(types.length, 0) @size = self.class.size types end |