Class | DL::CUnionEntity
In: | dl/lib/dl/struct.rb
Parent: | CStructEntity

### Methods

malloc set_ctypes size

### Included Modules

PackInfo

### Public Class methods

malloc(types, func=nil)

[Source]

    # File dl/lib/dl/struct.rb, line 166
        def CUnionEntity.malloc(types, func=nil)
          addr = DL.malloc(CUnionEntity.size(types))
          CUnionEntity.new(addr, types, func)
        end

size(types)

[Source]

    # File dl/lib/dl/struct.rb, line 171
        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

### Public Instance methods

set_ctypes(types)

[Source]

    # File dl/lib/dl/struct.rb, line 185
        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

[Validate]