A C union wrapper
Allocates a C union the types
provided. The C function
func
is called when the instance is garbage collected.
# File dl/lib/dl/struct.rb, line 212 def CUnionEntity.malloc(types, func=nil) addr = DL.malloc(CUnionEntity.size(types)) CUnionEntity.new(addr, types, func) end
Given types
, returns the size needed for the union.
DL::CUnionEntity.size([DL::TYPE_DOUBLE, DL::TYPE_INT, DL::TYPE_CHAR, DL::TYPE_VOIDP]) => 8
# File dl/lib/dl/struct.rb, line 222 def CUnionEntity.size(types) types.map { |type, count = 1| PackInfo::SIZE_MAP[type] * count }.max end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.