A C union wrapper
Methods
- M
- S
Class Public methods
malloc(types, func=nil)
Link
Allocates a C union the types
provided.
When the instance is garbage collected, the C
function func is called.
Source: show
# File ext/fiddle/lib/fiddle/struct.rb, line 216 def CUnionEntity.malloc(types, func=nil) addr = Fiddle.malloc(CUnionEntity.size(types)) CUnionEntity.new(addr, types, func) end
size(types)
Link
Returns the size needed for the union with the given types.
Fiddle::CUnionEntity.size(
[ Fiddle::TYPE_DOUBLE,
Fiddle::TYPE_INT,
Fiddle::TYPE_CHAR,
Fiddle::TYPE_VOIDP ]) #=> 8
Source: show
# File ext/fiddle/lib/fiddle/struct.rb, line 228 def CUnionEntity.size(types) types.map { |type, count = 1| PackInfo::SIZE_MAP[type] * count }.max end
Instance Public methods