nixenvironment 0.0.118 → 0.0.119

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39ce820fdfc8a2e27fdd564d5eb57fc1db5db17a
4
- data.tar.gz: e05a7419b8aad1b491c99b85e68d61ad635392bb
3
+ metadata.gz: f0e96e5fe4df37717bf6b14eb487fb131da8f7d9
4
+ data.tar.gz: 3ba99134ec7b12014cf5ccd89cf94ee2e2204517
5
5
  SHA512:
6
- metadata.gz: 4108e1f713ac5219ede699306e692ed9a65007a740eefba5c847473424c5c67775eab953f4442cbbf1a111c71f5ae04a44ecc7432e775b780f7c4940aa808b3b
7
- data.tar.gz: 694f169d9c3b8e0f5bec3f31ae1c4da095a5a7164f4b126c492530f950a6dce2b30ab4ea368497a8ac354eeea27ab08b146715d51c4d580fce1d58faeef424f3
6
+ metadata.gz: 59684e28698a111fae0574bb07728cc3e051013f728beb82bd167d3755fe47286acc44190083d6d96e80f70e6be21b5634897bff145eece0be1795a1ec978119
7
+ data.tar.gz: 114749bd49b54bbfe57f37ed54374621ed2cf4d6f5d2214a1b7b5021a42df1f3f88423c896fc827ff84ba6dcd6a26b19fd74d688169d88fe3610425d9edb25b5
data/bin/nixenvironment CHANGED
@@ -14,15 +14,6 @@ require 'xcodeproj'
14
14
 
15
15
  include Nixenvironment
16
16
 
17
- # ------------ WARNING: Удалить это если не поможет с крешем https://github.com/CocoaPods/CocoaPods/issues/2483#issuecomment-57505048
18
- require 'CFPropertyList'
19
- require 'CFPropertyList/rbNokogiriParser'
20
-
21
- def CFPropertyList.xml_parser_interface
22
- CFPropertyList::NokogiriXMLParser
23
- end
24
- # ------------------------------------------------
25
-
26
17
  CONFIG_SETTINGS_FILE_PATH = File.join(File.dirname(__FILE__), CONFIG_SETTINGS_FILE_NAME)
27
18
 
28
19
  program :name, 'nixenvironment'
@@ -606,14 +597,6 @@ def unity_build(configuration, unity_platform, unity_path, development_build, co
606
597
  unity_success = system("#{unity_path} -projectPath '#{Dir.pwd}' -batchmode -logFile -quit -executeMethod NIXBuilder.MakeiOSBuild -customArgs:'#{build_path_arg}#{development_build_arg}#{connect_profiler_arg}'")
607
598
  error('iOS build unity error!') unless unity_success
608
599
  success("IOS project was generated.\n")
609
-
610
- project_path = "#{UNITY_IOS_PROJECT_PATH}/Unity-iPhone.xcodeproj"
611
- project = Xcodeproj::Project.open(project_path)
612
- project.targets.each do |target|
613
- target.build_configurations.each do |config|
614
- config.build_settings['PLIST_FILE_OUTPUT_FORMAT'] = 'XML'
615
- end
616
- end
617
600
  when 'macos'
618
601
  build_path_arg = "buildPath=#{UNITY_MACOS_BUILD_PATH}"
619
602
  development_build_arg = development_build ? ';developmentBuild=' : ''
@@ -0,0 +1,44 @@
1
+ CFPropertyList implementation
2
+ class to read, manipulate and write both XML and binary property list
3
+ files (plist(5)) as defined by Apple. Have a look at CFPropertyList::List
4
+ for more documentation.
5
+
6
+ == Installation
7
+
8
+ You could either use ruby gems and install it via
9
+
10
+ gem install CFPropertyList
11
+
12
+ or you could clone this repository and place it somewhere in your load path.
13
+
14
+ == Example
15
+ require 'cfpropertylist'
16
+
17
+ # create a arbitrary data structure of basic data types
18
+ data = {
19
+ 'name' => 'John Doe',
20
+ 'missing' => true,
21
+ 'last_seen' => Time.now,
22
+ 'friends' => ['Jane Doe','Julian Doe'],
23
+ 'likes' => {
24
+ 'me' => false
25
+ }
26
+ }
27
+
28
+ # create CFPropertyList::List object
29
+ plist = CFPropertyList::List.new
30
+
31
+ # call CFPropertyList.guess() to create corresponding CFType values
32
+ plist.value = CFPropertyList.guess(data)
33
+
34
+ # write plist to file
35
+ plist.save("example.plist", CFPropertyList::List::FORMAT_BINARY)
36
+
37
+ # … later, read it again
38
+ plist = CFPropertyList::List.new(:file => "example.plist")
39
+ data = CFPropertyList.native_types(plist.value)
40
+
41
+ Author:: Christian Kruse (mailto:cjk@wwwtech.de)
42
+ Copyright:: Copyright (c) 2010
43
+ License:: MIT License
44
+
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'cfpropertylist/rbCFPropertyList'
4
+
5
+
6
+ # eof
@@ -0,0 +1,605 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'stringio'
4
+
5
+ module CFPropertyList228
6
+ # Binary PList parser class
7
+ class Binary
8
+ # Read a binary plist file
9
+ def load(opts)
10
+ @unique_table = {}
11
+ @count_objects = 0
12
+ @object_refs = 0
13
+
14
+ @written_object_count = 0
15
+ @object_table = []
16
+ @object_ref_size = 0
17
+
18
+ @offsets = []
19
+
20
+ fd = nil
21
+ if(opts.has_key?(:file))
22
+ fd = File.open(opts[:file],"rb")
23
+ file = opts[:file]
24
+ else
25
+ fd = StringIO.new(opts[:data],"rb")
26
+ file = "<string>"
27
+ end
28
+
29
+ # first, we read the trailer: 32 byte from the end
30
+ fd.seek(-32,IO::SEEK_END)
31
+ buff = fd.read(32)
32
+
33
+ offset_size, object_ref_size, number_of_objects, top_object, table_offset = buff.unpack "x6CCx4Nx4Nx4N"
34
+
35
+ # after that, get the offset table
36
+ fd.seek(table_offset, IO::SEEK_SET)
37
+ coded_offset_table = fd.read(number_of_objects * offset_size)
38
+ raise CFFormatError.new("#{file}: Format error!") unless coded_offset_table.bytesize == number_of_objects * offset_size
39
+
40
+ @count_objects = number_of_objects
41
+
42
+ # decode offset table
43
+ if(offset_size != 3)
44
+ formats = ["","C*","n*","","N*"]
45
+ @offsets = coded_offset_table.unpack(formats[offset_size])
46
+ else
47
+ @offsets = coded_offset_table.unpack("C*").each_slice(3).map {
48
+ |x,y,z| (x << 16) | (y << 8) | z
49
+ }
50
+ end
51
+
52
+ @object_ref_size = object_ref_size
53
+ val = read_binary_object_at(file,fd,top_object)
54
+
55
+ fd.close
56
+ val
57
+ end
58
+
59
+
60
+ # Convert CFPropertyList228 to binary format; since we have to count our objects we simply unique CFDictionary and CFArray
61
+ def to_str(opts={})
62
+ @unique_table = {}
63
+ @count_objects = 0
64
+ @object_refs = 0
65
+
66
+ @written_object_count = 0
67
+ @object_table = []
68
+
69
+ @offsets = []
70
+
71
+ binary_str = "bplist00"
72
+
73
+ @object_refs = count_object_refs(opts[:root])
74
+
75
+ opts[:root].to_binary(self)
76
+
77
+ next_offset = 8
78
+ offsets = @object_table.map do |object|
79
+ offset = next_offset
80
+ next_offset += object.bytesize
81
+ offset
82
+ end
83
+ binary_str << @object_table.join
84
+
85
+ table_offset = next_offset
86
+ offset_size = Binary.bytes_needed(table_offset)
87
+
88
+ if offset_size < 8
89
+ # Fast path: encode the entire offset array at once.
90
+ binary_str << offsets.pack((%w(C n N N)[offset_size - 1]) + '*')
91
+ else
92
+ # Slow path: host may be little or big endian, must pack each offset
93
+ # separately.
94
+ offsets.each do |offset|
95
+ binary_str << "#{Binary.pack_it_with_size(offset_size,offset)}"
96
+ end
97
+ end
98
+
99
+ binary_str << [offset_size, object_ref_size(@object_refs)].pack("x6CC")
100
+ binary_str << [@object_table.size].pack("x4N")
101
+ binary_str << [0].pack("x4N")
102
+ binary_str << [table_offset].pack("x4N")
103
+
104
+ binary_str
105
+ end
106
+
107
+ def object_ref_size object_refs
108
+ Binary.bytes_needed(object_refs)
109
+ end
110
+
111
+ # read a „null” type (i.e. null byte, marker byte, bool value)
112
+ def read_binary_null_type(length)
113
+ case length
114
+ when 0 then 0 # null byte
115
+ when 8 then CFBoolean.new(false)
116
+ when 9 then CFBoolean.new(true)
117
+ when 15 then 15 # fill type
118
+ else
119
+ raise CFFormatError.new("unknown null type: #{length}")
120
+ end
121
+ end
122
+ protected :read_binary_null_type
123
+
124
+ # read a binary int value
125
+ def read_binary_int(fname,fd,length)
126
+ if length > 3
127
+ raise CFFormatError.new("Integer greater than 8 bytes: #{length}")
128
+ end
129
+
130
+ nbytes = 1 << length
131
+
132
+ buff = fd.read(nbytes)
133
+
134
+ CFInteger.new(
135
+ case length
136
+ when 0 then buff.unpack("C")[0]
137
+ when 1 then buff.unpack("n")[0]
138
+ when 2 then buff.unpack("N")[0]
139
+ when 3
140
+ hiword,loword = buff.unpack("NN")
141
+ if (hiword & 0x80000000) != 0
142
+ # 8 byte integers are always signed, and are negative when bit 63 is
143
+ # set. Decoding into either a Fixnum or Bignum is tricky, however,
144
+ # because the size of a Fixnum varies among systems, and Ruby
145
+ # doesn't consider the number to be negative, and won't sign extend.
146
+ -(2**63 - ((hiword & 0x7fffffff) << 32 | loword))
147
+ else
148
+ hiword << 32 | loword
149
+ end
150
+ end
151
+ )
152
+ end
153
+ protected :read_binary_int
154
+
155
+ # read a binary real value
156
+ def read_binary_real(fname,fd,length)
157
+ raise CFFormatError.new("Real greater than 8 bytes: #{length}") if length > 3
158
+
159
+ nbytes = 1 << length
160
+ buff = fd.read(nbytes)
161
+
162
+ CFReal.new(
163
+ case length
164
+ when 0 # 1 byte float? must be an error
165
+ raise CFFormatError.new("got #{length+1} byte float, must be an error!")
166
+ when 1 # 2 byte float? must be an error
167
+ raise CFFormatError.new("got #{length+1} byte float, must be an error!")
168
+ when 2 then
169
+ buff.reverse.unpack("f")[0]
170
+ when 3 then
171
+ buff.reverse.unpack("d")[0]
172
+ else
173
+ fail "unexpected length: #{length}"
174
+ end
175
+ )
176
+ end
177
+ protected :read_binary_real
178
+
179
+ # read a binary date value
180
+ def read_binary_date(fname,fd,length)
181
+ raise CFFormatError.new("Date greater than 8 bytes: #{length}") if length > 3
182
+
183
+ nbytes = 1 << length
184
+ buff = fd.read(nbytes)
185
+
186
+ CFDate.new(
187
+ case length
188
+ when 0 then # 1 byte CFDate is an error
189
+ raise CFFormatError.new("#{length+1} byte CFDate, error")
190
+ when 1 then # 2 byte CFDate is an error
191
+ raise CFFormatError.new("#{length+1} byte CFDate, error")
192
+ when 2 then
193
+ buff.reverse.unpack("f")[0]
194
+ when 3 then
195
+ buff.reverse.unpack("d")[0]
196
+ end,
197
+ CFDate::TIMESTAMP_APPLE
198
+ )
199
+ end
200
+ protected :read_binary_date
201
+
202
+ # Read a binary data value
203
+ def read_binary_data(fname,fd,length)
204
+ CFData.new(read_fd(fd, length), CFData::DATA_RAW)
205
+ end
206
+ protected :read_binary_data
207
+
208
+ def read_fd fd, length
209
+ length > 0 ? fd.read(length) : ""
210
+ end
211
+
212
+ # Read a binary string value
213
+ def read_binary_string(fname,fd,length)
214
+ buff = read_fd fd, length
215
+ @unique_table[buff] = true unless @unique_table.has_key?(buff)
216
+ CFString.new(buff)
217
+ end
218
+ protected :read_binary_string
219
+
220
+ # Convert the given string from one charset to another
221
+ def Binary.charset_convert(str,from,to="UTF-8")
222
+ return str.dup.force_encoding(from).encode(to) if str.respond_to?("encode")
223
+ Iconv.conv(to,from,str)
224
+ end
225
+
226
+ # Count characters considering character set
227
+ def Binary.charset_strlen(str,charset="UTF-8")
228
+ if str.respond_to?(:encode)
229
+ size = str.length
230
+ else
231
+ utf8_str = Iconv.conv("UTF-8",charset,str)
232
+ size = utf8_str.scan(/./mu).size
233
+ end
234
+
235
+ # UTF-16 code units in the range D800-DBFF are the beginning of
236
+ # a surrogate pair, and count as one additional character for
237
+ # length calculation.
238
+ if charset =~ /^UTF-16/
239
+ if str.respond_to?(:encode)
240
+ str.bytes.to_a.each_slice(2) { |pair| size += 1 if (0xd8..0xdb).include?(pair[0]) }
241
+ else
242
+ str.split('').each_slice(2) { |pair| size += 1 if ("\xd8".."\xdb").include?(pair[0]) }
243
+ end
244
+ end
245
+
246
+ size
247
+ end
248
+
249
+ # Read a unicode string value, coded as UTF-16BE
250
+ def read_binary_unicode_string(fname,fd,length)
251
+ # The problem is: we get the length of the string IN CHARACTERS;
252
+ # since a char in UTF-16 can be 16 or 32 bit long, we don't really know
253
+ # how long the string is in bytes
254
+ buff = fd.read(2*length)
255
+
256
+ @unique_table[buff] = true unless @unique_table.has_key?(buff)
257
+ CFString.new(Binary.charset_convert(buff,"UTF-16BE","UTF-8"))
258
+ end
259
+ protected :read_binary_unicode_string
260
+
261
+ def unpack_with_size(nbytes, buff)
262
+ format = ["C*", "n*", "N*", "N*"][nbytes - 1];
263
+
264
+ if nbytes == 3
265
+ buff = "\0" + buff.scan(/.{1,3}/).join("\0")
266
+ end
267
+
268
+ return buff.unpack(format)
269
+ end
270
+
271
+ # Read an binary array value, including contained objects
272
+ def read_binary_array(fname,fd,length)
273
+ ary = []
274
+
275
+ # first: read object refs
276
+ if(length != 0)
277
+ buff = fd.read(length * @object_ref_size)
278
+ objects = unpack_with_size(@object_ref_size, buff) #buff.unpack(@object_ref_size == 1 ? "C*" : "n*")
279
+
280
+ # now: read objects
281
+ 0.upto(length-1) do |i|
282
+ object = read_binary_object_at(fname,fd,objects[i])
283
+ ary.push object
284
+ end
285
+ end
286
+
287
+ CFArray.new(ary)
288
+ end
289
+ protected :read_binary_array
290
+
291
+ # Read a dictionary value, including contained objects
292
+ def read_binary_dict(fname,fd,length)
293
+ dict = {}
294
+
295
+ # first: read keys
296
+ if(length != 0) then
297
+ buff = fd.read(length * @object_ref_size)
298
+ keys = unpack_with_size(@object_ref_size, buff)
299
+
300
+ # second: read object refs
301
+ buff = fd.read(length * @object_ref_size)
302
+ objects = unpack_with_size(@object_ref_size, buff)
303
+
304
+ # read real keys and objects
305
+ 0.upto(length-1) do |i|
306
+ key = read_binary_object_at(fname,fd,keys[i])
307
+ object = read_binary_object_at(fname,fd,objects[i])
308
+ dict[key.value] = object
309
+ end
310
+ end
311
+
312
+ CFDictionary.new(dict)
313
+ end
314
+ protected :read_binary_dict
315
+
316
+ # Read an object type byte, decode it and delegate to the correct
317
+ # reader function
318
+ def read_binary_object(fname,fd)
319
+ # first: read the marker byte
320
+ buff = fd.read(1)
321
+
322
+ object_length = buff.unpack("C*")
323
+ object_length = object_length[0] & 0xF
324
+
325
+ buff = buff.unpack("H*")
326
+ object_type = buff[0][0].chr
327
+
328
+ if(object_type != "0" && object_length == 15) then
329
+ object_length = read_binary_object(fname,fd)
330
+ object_length = object_length.value
331
+ end
332
+
333
+ case object_type
334
+ when '0' # null, false, true, fillbyte
335
+ read_binary_null_type(object_length)
336
+ when '1' # integer
337
+ read_binary_int(fname,fd,object_length)
338
+ when '2' # real
339
+ read_binary_real(fname,fd,object_length)
340
+ when '3' # date
341
+ read_binary_date(fname,fd,object_length)
342
+ when '4' # data
343
+ read_binary_data(fname,fd,object_length)
344
+ when '5' # byte string, usually utf8 encoded
345
+ read_binary_string(fname,fd,object_length)
346
+ when '6' # unicode string (utf16be)
347
+ read_binary_unicode_string(fname,fd,object_length)
348
+ when '8'
349
+ CFUid.new(read_binary_int(fname, fd, object_length).value)
350
+ when 'a' # array
351
+ read_binary_array(fname,fd,object_length)
352
+ when 'd' # dictionary
353
+ read_binary_dict(fname,fd,object_length)
354
+ end
355
+ end
356
+ protected :read_binary_object
357
+
358
+ # Read an object type byte at position $pos, decode it and delegate to the correct reader function
359
+ def read_binary_object_at(fname,fd,pos)
360
+ position = @offsets[pos]
361
+ fd.seek(position,IO::SEEK_SET)
362
+ read_binary_object(fname,fd)
363
+ end
364
+ protected :read_binary_object_at
365
+
366
+ # pack an +int+ of +nbytes+ with size
367
+ def Binary.pack_it_with_size(nbytes,int)
368
+ case nbytes
369
+ when 1 then [int].pack('c')
370
+ when 2 then [int].pack('n')
371
+ when 4 then [int].pack('N')
372
+ when 8
373
+ [int >> 32, int & 0xFFFFFFFF].pack('NN')
374
+ else
375
+ raise CFFormatError.new("Don't know how to pack #{nbytes} byte integer")
376
+ end
377
+ end
378
+
379
+ def Binary.pack_int_array_with_size(nbytes, array)
380
+ case nbytes
381
+ when 1 then array.pack('C*')
382
+ when 2 then array.pack('n*')
383
+ when 4 then array.pack('N*')
384
+ when 8
385
+ array.map { |int| [int >> 32, int & 0xFFFFFFFF].pack('NN') }.join
386
+ else
387
+ raise CFFormatError.new("Don't know how to pack #{nbytes} byte integer")
388
+ end
389
+ end
390
+
391
+ # calculate how many bytes are needed to save +count+
392
+ def Binary.bytes_needed(count)
393
+ case
394
+ when count < 2**8 then 1
395
+ when count < 2**16 then 2
396
+ when count < 2**32 then 4
397
+ when count < 2**64 then 8
398
+ else
399
+ raise CFFormatError.new("Data size too large: #{count}")
400
+ end
401
+ end
402
+
403
+ # Create a type byte for binary format as defined by apple
404
+ def Binary.type_bytes(type, length)
405
+ if length < 15
406
+ [(type << 4) | length].pack('C')
407
+ else
408
+ bytes = [(type << 4) | 0xF]
409
+ if length <= 0xFF
410
+ bytes.push(0x10, length).pack('CCC') # 1 byte length
411
+ elsif length <= 0xFFFF
412
+ bytes.push(0x11, length).pack('CCn') # 2 byte length
413
+ elsif length <= 0xFFFFFFFF
414
+ bytes.push(0x12, length).pack('CCN') # 4 byte length
415
+ elsif length <= 0x7FFFFFFFFFFFFFFF
416
+ bytes.push(0x13, length >> 32, length & 0xFFFFFFFF).pack('CCNN') # 8 byte length
417
+ else
418
+ raise CFFormatError.new("Integer too large: #{int}")
419
+ end
420
+ end
421
+ end
422
+
423
+ def count_object_refs(object)
424
+ case object
425
+ when CFArray
426
+ contained_refs = 0
427
+ object.value.each do |element|
428
+ if CFArray === element || CFDictionary === element
429
+ contained_refs += count_object_refs(element)
430
+ end
431
+ end
432
+ return object.value.size + contained_refs
433
+ when CFDictionary
434
+ contained_refs = 0
435
+ object.value.each_value do |value|
436
+ if CFArray === value || CFDictionary === value
437
+ contained_refs += count_object_refs(value)
438
+ end
439
+ end
440
+ return object.value.keys.size * 2 + contained_refs
441
+ else
442
+ return 0
443
+ end
444
+ end
445
+
446
+ def Binary.ascii_string?(str)
447
+ if str.respond_to?(:ascii_only?)
448
+ str.ascii_only?
449
+ else
450
+ str !~ /[\x80-\xFF]/mn
451
+ end
452
+ end
453
+
454
+ # Uniques and transforms a string value to binary format and adds it to the object table
455
+ def string_to_binary(val)
456
+ val = val.to_s
457
+
458
+ @unique_table[val] ||= begin
459
+ if !Binary.ascii_string?(val)
460
+ val = Binary.charset_convert(val,"UTF-8","UTF-16BE")
461
+ bdata = Binary.type_bytes(0b0110, Binary.charset_strlen(val,"UTF-16BE"))
462
+
463
+ val.force_encoding("ASCII-8BIT") if val.respond_to?("encode")
464
+ @object_table[@written_object_count] = bdata << val
465
+ else
466
+ bdata = Binary.type_bytes(0b0101,val.bytesize)
467
+ @object_table[@written_object_count] = bdata << val
468
+ end
469
+
470
+ @written_object_count += 1
471
+ @written_object_count - 1
472
+ end
473
+ end
474
+
475
+ # Codes an integer to binary format
476
+ def int_to_binary(value)
477
+ nbytes = 0
478
+ nbytes = 1 if value > 0xFF # 1 byte integer
479
+ nbytes += 1 if value > 0xFFFF # 4 byte integer
480
+ nbytes += 1 if value > 0xFFFFFFFF # 8 byte integer
481
+ nbytes = 3 if value < 0 # 8 byte integer, since signed
482
+
483
+ Binary.type_bytes(0b0001, nbytes) <<
484
+ if nbytes < 3
485
+ [value].pack(
486
+ if nbytes == 0 then "C"
487
+ elsif nbytes == 1 then "n"
488
+ else "N"
489
+ end
490
+ )
491
+ else
492
+ # 64 bit signed integer; we need the higher and the lower 32 bit of the value
493
+ high_word = value >> 32
494
+ low_word = value & 0xFFFFFFFF
495
+ [high_word,low_word].pack("NN")
496
+ end
497
+ end
498
+
499
+ # Codes a real value to binary format
500
+ def real_to_binary(val)
501
+ Binary.type_bytes(0b0010,3) << [val].pack("d").reverse
502
+ end
503
+
504
+ # Converts a numeric value to binary and adds it to the object table
505
+ def num_to_binary(value)
506
+ @object_table[@written_object_count] =
507
+ if value.is_a?(CFInteger)
508
+ int_to_binary(value.value)
509
+ else
510
+ real_to_binary(value.value)
511
+ end
512
+
513
+ @written_object_count += 1
514
+ @written_object_count - 1
515
+ end
516
+
517
+ def uid_to_binary(value)
518
+ nbytes = 0
519
+ nbytes = 1 if value > 0xFF # 1 byte integer
520
+ nbytes += 1 if value > 0xFFFF # 4 byte integer
521
+ nbytes += 1 if value > 0xFFFFFFFF # 8 byte integer
522
+ nbytes = 3 if value < 0 # 8 byte integer, since signed
523
+
524
+ @object_table[@written_object_count] = Binary.type_bytes(0b1000, nbytes) <<
525
+ if nbytes < 3
526
+ [value].pack(
527
+ if nbytes == 0 then "C"
528
+ elsif nbytes == 1 then "n"
529
+ else "N"
530
+ end
531
+ )
532
+ else
533
+ # 64 bit signed integer; we need the higher and the lower 32 bit of the value
534
+ high_word = value >> 32
535
+ low_word = value & 0xFFFFFFFF
536
+ [high_word,low_word].pack("NN")
537
+ end
538
+
539
+ @written_object_count += 1
540
+ @written_object_count - 1
541
+ end
542
+
543
+ # Convert date value (apple format) to binary and adds it to the object table
544
+ def date_to_binary(val)
545
+ val = val.getutc.to_f - CFDate::DATE_DIFF_APPLE_UNIX # CFDate is a real, number of seconds since 01/01/2001 00:00:00 GMT
546
+
547
+ @object_table[@written_object_count] =
548
+ (Binary.type_bytes(0b0011, 3) << [val].pack("d").reverse)
549
+
550
+ @written_object_count += 1
551
+ @written_object_count - 1
552
+ end
553
+
554
+ # Convert a bool value to binary and add it to the object table
555
+ def bool_to_binary(val)
556
+
557
+ @object_table[@written_object_count] = val ? "\x9" : "\x8" # 0x9 is 1001, type indicator for true; 0x8 is 1000, type indicator for false
558
+ @written_object_count += 1
559
+ @written_object_count - 1
560
+ end
561
+
562
+ # Convert data value to binary format and add it to the object table
563
+ def data_to_binary(val)
564
+ @object_table[@written_object_count] =
565
+ (Binary.type_bytes(0b0100, val.bytesize) << val)
566
+
567
+ @written_object_count += 1
568
+ @written_object_count - 1
569
+ end
570
+
571
+ # Convert array to binary format and add it to the object table
572
+ def array_to_binary(val)
573
+ saved_object_count = @written_object_count
574
+ @written_object_count += 1
575
+ #@object_refs += val.value.size
576
+
577
+ values = val.value.map { |v| v.to_binary(self) }
578
+ bdata = Binary.type_bytes(0b1010, val.value.size) <<
579
+ Binary.pack_int_array_with_size(object_ref_size(@object_refs),
580
+ values)
581
+
582
+ @object_table[saved_object_count] = bdata
583
+ saved_object_count
584
+ end
585
+
586
+ # Convert dictionary to binary format and add it to the object table
587
+ def dict_to_binary(val)
588
+ saved_object_count = @written_object_count
589
+ @written_object_count += 1
590
+
591
+ #@object_refs += val.value.keys.size * 2
592
+
593
+ keys_and_values = val.value.keys.map { |k| CFString.new(k).to_binary(self) }
594
+ keys_and_values.concat(val.value.values.map { |v| v.to_binary(self) })
595
+
596
+ bdata = Binary.type_bytes(0b1101,val.value.size) <<
597
+ Binary.pack_int_array_with_size(object_ref_size(@object_refs), keys_and_values)
598
+
599
+ @object_table[saved_object_count] = bdata
600
+ return saved_object_count
601
+ end
602
+ end
603
+ end
604
+
605
+ # eof