Class | DL::Stack
In: | dl/lib/dl/stack.rb
Parent: | Object

### Methods

[] new pack size types unpack

### Constants

ALIGN_MAP | = | { TYPE_VOIDP => ALIGN_VOIDP, TYPE_CHAR => ALIGN_VOIDP, TYPE_SHORT => ALIGN_VOIDP, TYPE_INT => ALIGN_VOIDP, TYPE_LONG => ALIGN_VOIDP, TYPE_LONG_LONG => ALIGN_LONG_LONG, TYPE_FLOAT => ALIGN_FLOAT, TYPE_DOUBLE => ALIGN_DOUBLE, }
PACK_MAP | = | { TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG)? "q" : "l!"), TYPE_CHAR => "c", TYPE_SHORT => "s!", TYPE_INT => "i!", TYPE_LONG => "l!", TYPE_LONG_LONG => "q", TYPE_FLOAT => "f", TYPE_DOUBLE => "d", }
SIZE_MAP | = | { TYPE_VOIDP => SIZEOF_VOIDP, TYPE_CHAR => SIZEOF_CHAR, TYPE_SHORT => SIZEOF_SHORT, TYPE_INT => SIZEOF_INT, TYPE_LONG => SIZEOF_LONG, TYPE_LONG_LONG => SIZEOF_LONG_LONG, TYPE_FLOAT => SIZEOF_FLOAT, TYPE_DOUBLE => SIZEOF_DOUBLE, }
ALIGN_MAP | = | { TYPE_VOIDP => ALIGN_VOIDP, TYPE_CHAR => ALIGN_VOIDP, TYPE_SHORT => ALIGN_VOIDP, TYPE_INT => ALIGN_VOIDP, TYPE_LONG => ALIGN_VOIDP, TYPE_FLOAT => ALIGN_FLOAT, TYPE_DOUBLE => ALIGN_DOUBLE, }
PACK_MAP | = | { TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG)? "q" : "l!"), TYPE_CHAR => "c", TYPE_SHORT => "s!", TYPE_INT => "i!", TYPE_LONG => "l!", TYPE_FLOAT => "f", TYPE_DOUBLE => "d", }
SIZE_MAP | = | { TYPE_VOIDP => SIZEOF_VOIDP, TYPE_CHAR => SIZEOF_CHAR, TYPE_SHORT => SIZEOF_SHORT, TYPE_INT => SIZEOF_INT, TYPE_LONG => SIZEOF_LONG, TYPE_FLOAT => SIZEOF_FLOAT, TYPE_DOUBLE => SIZEOF_DOUBLE, }

### Public Class methods

[](*types)

[Source]

    # File dl/lib/dl/stack.rb, line 5
        def Stack.[](*types)
          Stack.new(types)
        end

new(types)

[Source]

    # File dl/lib/dl/stack.rb, line 9
        def initialize(types)
          parse_types(types)
        end

### Public Instance methods

pack(ary)

[Source]

    # File dl/lib/dl/stack.rb, line 21
        def pack(ary)
          case SIZEOF_VOIDP
          when SIZEOF_LONG
            ary.pack(@template).unpack('l!*')
          when SIZEOF_LONG
            ary.pack(@template).unpack('q*')
          else
            raise(RuntimeError, "sizeof(void*)?")
          end
        end

size()

[Source]

    # File dl/lib/dl/stack.rb, line 13
        def size()
          @size
        end

types()

[Source]

    # File dl/lib/dl/stack.rb, line 17
        def types()
          @types
        end

unpack(ary)

[Source]

    # File dl/lib/dl/stack.rb, line 32
        def unpack(ary)
          case SIZEOF_VOIDP
          when SIZEOF_LONG
            ary.pack('l!*').unpack(@template)
          when SIZEOF_LONG_LONG
            ary.pack('q*').unpack(@template)
          else
            raise(RuntimeError, "sizeof(void*)?")
          end
        end

[Validate]