gvariant 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gvariant.rb +13 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a6a26869531605658d5c8bf0728a6314a52ad70
|
4
|
+
data.tar.gz: a443669cb24d08404aba807d268bae4ecd2fa5b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb887198d040635e5e53d907957750b2811db75663bf2c87a559d2923093c47cd994f42172d93ac658052c5374516935ad8d555b2bdf3d839c76d8869005a796
|
7
|
+
data.tar.gz: ac1939395cd79f54c3fff582d421ab4accca74b86974a867aaf6043af00429143c5bf4cebf44f26b1a890cf0d035628948881a08eac9a56f781bab3be9371927
|
data/lib/gvariant.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class GVariantBasicType
|
2
2
|
attr_reader :id, :fixed_size, :default_value, :alignment
|
3
3
|
|
4
|
-
def initialize(id,
|
4
|
+
def initialize(id, pack_format, alignment, fixed_size, default_value)
|
5
5
|
@id, @pack_format, @alignment, @fixed_size, @default_value =
|
6
|
-
id,
|
6
|
+
id, pack_format, alignment, fixed_size, default_value
|
7
7
|
end
|
8
8
|
|
9
9
|
def align(i)
|
@@ -170,7 +170,7 @@ class GVariantOffsetType < GVariantBasicType
|
|
170
170
|
packed = ""
|
171
171
|
|
172
172
|
loop do
|
173
|
-
determine_offset_type(buf.length + packed_size)
|
173
|
+
determine_offset_type(buf.length + packed_size, false)
|
174
174
|
break if @offset_size == offset_size_prev
|
175
175
|
offset_size_prev = @offset_size
|
176
176
|
|
@@ -183,8 +183,8 @@ class GVariantOffsetType < GVariantBasicType
|
|
183
183
|
|
184
184
|
private
|
185
185
|
|
186
|
-
def determine_offset_type(l)
|
187
|
-
if @offset_size.nil?
|
186
|
+
def determine_offset_type(l, use_cache = true)
|
187
|
+
if @offset_size.nil? || !use_cache
|
188
188
|
if (l < 0xff)
|
189
189
|
@offset_size = 1
|
190
190
|
@offset_pack_format = 'C'
|
@@ -226,7 +226,8 @@ class GVariantDictionaryType < GVariantOffsetType
|
|
226
226
|
value_end = buf.length - @offset_size
|
227
227
|
end
|
228
228
|
|
229
|
-
key = @key_element.read(buf[0..key_end - 1])
|
229
|
+
key = @key_element.read(buf[0..key_end - 1])
|
230
|
+
key = key.to_sym if key.is_a? String
|
230
231
|
value = @value_element.read(buf[@value_element.align(key_end)..value_end - 1])
|
231
232
|
|
232
233
|
Hash[key, value]
|
@@ -272,7 +273,7 @@ class GVariantArrayType < GVariantOffsetType
|
|
272
273
|
c = 0
|
273
274
|
|
274
275
|
if (@element.fixed_size)
|
275
|
-
return
|
276
|
+
return @default_value if (size % @element.fixed_size != 0)
|
276
277
|
n = size / @element.fixed_size
|
277
278
|
|
278
279
|
n.times do
|
@@ -401,7 +402,7 @@ class GVariant
|
|
401
402
|
GVariantUnsignedShortType.new
|
402
403
|
when 'i'
|
403
404
|
GVariantSignedIntType.new
|
404
|
-
when 'u'
|
405
|
+
when 'u', 'h'
|
405
406
|
GVariantUnsignedIntType.new
|
406
407
|
when 'x'
|
407
408
|
GVariantSignedLongType.new
|
@@ -442,11 +443,11 @@ class GVariant
|
|
442
443
|
end
|
443
444
|
end
|
444
445
|
|
445
|
-
def self.parse_type(
|
446
|
-
type = next_type(
|
446
|
+
def self.parse_type(typestr)
|
447
|
+
type = next_type(typestr, 0)
|
447
448
|
|
448
|
-
if type.nil? || type.id.length !=
|
449
|
-
raise ArgumentError.new("Invalid type string: #{
|
449
|
+
if type.nil? || type.id.length != typestr.length
|
450
|
+
raise ArgumentError.new("Invalid type string: #{typestr}")
|
450
451
|
end
|
451
452
|
|
452
453
|
type
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gvariant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Mack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple reader and writer for the GVariant serialization format
|
14
14
|
email: github@zonque.org
|