Object
Class that handles the conversion (unmarshalling) of payload data to Array.
Create a new unmarshaller for the given data buffer and endianness.
# File lib/dbus/marshall.rb, line 34 def initialize(buffer, endianness) @buffy, @endianness = buffer.dup, endianness if @endianness == BIG_END @uint32 = "N" @uint16 = "n" @double = "G" elsif @endianness == LIL_END @uint32 = "V" @uint16 = "v" @double = "E" else raise InvalidPacketException, "Incorrect endianness #{@endianness}" end @idx = 0 end
Align the pointer index on a byte index of a, where a must be 1, 2, 4 or 8.
# File lib/dbus/marshall.rb, line 68 def align(a) case a when 1 when 2, 4, 8 bits = a - 1 @idx = @idx + bits & ~bits raise IncompleteBufferException if @idx > @buffy.bytesize else raise "Unsupported alignment #{a}" end end
Unmarshall the buffer for a given signature and length len. Return an array of unmarshalled objects
# File lib/dbus/marshall.rb, line 52 def unmarshall(signature, len = nil) if len != nil if @buffy.bytesize < @idx + len raise IncompleteBufferException end end sigtree = Type::Parser.new(signature).parse ret = Array.new sigtree.each do |elem| ret << do_parse(elem) end ret end
Generated with the Darkfish Rdoc Generator 2.