gobject-introspection 3.0.7-x86-mingw32 → 3.0.8-x86-mingw32

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.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/ext/gobject-introspection/extconf.rb +1 -0
  4. data/ext/gobject-introspection/rb-gi-argument.c +123 -26
  5. data/ext/gobject-introspection/rb-gi-function-info.c +558 -19
  6. data/ext/gobject-introspection/rb-gi-repository.c +9 -0
  7. data/ext/gobject-introspection/rb-gobject-introspection.h +3 -0
  8. data/lib/2.2/gobject_introspection.so +0 -0
  9. data/lib/2.3/gobject_introspection.so +0 -0
  10. data/lib/gobject-introspection/loader.rb +1 -1
  11. data/vendor/local/bin/g-ir-compiler.exe +0 -0
  12. data/vendor/local/bin/g-ir-generate.exe +0 -0
  13. data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
  14. data/vendor/local/include/gobject-introspection-1.0/gistructinfo.h +4 -0
  15. data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
  16. data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
  17. data/vendor/local/lib/girepository-1.0/GModule-2.0.typelib +0 -0
  18. data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
  19. data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
  20. data/vendor/local/lib/gobject-introspection/giscanner/__init__.py +1 -1
  21. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
  22. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
  23. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.py +39 -11
  24. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
  25. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
  26. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +187 -164
  27. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
  28. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
  29. data/vendor/local/lib/gobject-introspection/giscanner/ast.py +191 -58
  30. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
  31. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
  32. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.py +42 -54
  33. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
  34. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
  35. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.py +272 -82
  36. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyc +0 -0
  37. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyo +0 -0
  38. data/vendor/local/lib/gobject-introspection/giscanner/codegen.py +18 -11
  39. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
  40. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
  41. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.py +4 -0
  42. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyc +0 -0
  43. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyo +0 -0
  44. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyc +0 -0
  45. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyo +0 -0
  46. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.py +25 -13
  47. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyc +0 -0
  48. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyo +0 -0
  49. data/vendor/local/lib/gobject-introspection/giscanner/docmain.py +21 -19
  50. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
  51. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
  52. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.py +19 -16
  53. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
  54. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
  55. data/vendor/local/lib/gobject-introspection/giscanner/dumper.py +148 -158
  56. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
  57. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
  58. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.py +31 -21
  59. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
  60. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
  61. data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +13 -5
  62. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
  63. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
  64. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.py +12 -13
  65. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
  66. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
  67. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.py +5 -1
  68. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
  69. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
  70. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.py +11 -9
  71. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
  72. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
  73. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +150 -45
  74. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
  75. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
  76. data/vendor/local/lib/gobject-introspection/giscanner/message.py +56 -19
  77. data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
  78. data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
  79. data/vendor/local/lib/gobject-introspection/giscanner/msvccompiler.py +101 -0
  80. data/vendor/local/lib/gobject-introspection/giscanner/msvccompiler.pyc +0 -0
  81. data/vendor/local/lib/gobject-introspection/giscanner/msvccompiler.pyo +0 -0
  82. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +41 -22
  83. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
  84. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
  85. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.py +6 -1
  86. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
  87. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
  88. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.py +8 -2
  89. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
  90. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
  91. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +42 -56
  92. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
  93. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
  94. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.py +19 -5
  95. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
  96. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
  97. data/vendor/local/lib/gobject-introspection/giscanner/transformer.py +73 -37
  98. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
  99. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
  100. data/vendor/local/lib/gobject-introspection/giscanner/utils.py +92 -14
  101. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
  102. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
  103. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.py +30 -11
  104. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
  105. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
  106. data/vendor/local/lib/libgirepository-1.0.a +0 -0
  107. data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
  108. data/vendor/local/lib/libgirepository-1.0.la +1 -1
  109. data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +1 -1
  110. data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +1 -1
  111. data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +57 -13
  112. data/vendor/local/share/gir-1.0/GLib-2.0.gir +2018 -894
  113. data/vendor/local/share/gir-1.0/GModule-2.0.gir +2 -1
  114. data/vendor/local/share/gir-1.0/GObject-2.0.gir +1107 -674
  115. data/vendor/local/share/gir-1.0/Gio-2.0.gir +5589 -1287
  116. data/vendor/local/share/gobject-introspection-1.0/Makefile.introspection +4 -2
  117. data/vendor/local/share/gobject-introspection-1.0/gdump.c +8 -0
  118. data/vendor/local/share/gobject-introspection-1.0/tests/everything.c +273 -323
  119. data/vendor/local/share/gobject-introspection-1.0/tests/everything.h +58 -38
  120. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +1 -1
  121. data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +177 -23
  122. data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +40 -0
  123. data/vendor/local/share/man/man1/g-ir-compiler.1 +7 -7
  124. metadata +9 -7
  125. data/lib/2.0/gobject_introspection.so +0 -0
  126. data/lib/2.1/gobject_introspection.so +0 -0
@@ -19,7 +19,13 @@
19
19
  # Boston, MA 02111-1307, USA.
20
20
  #
21
21
 
22
+ from __future__ import absolute_import
23
+ from __future__ import division
24
+ from __future__ import print_function
25
+ from __future__ import unicode_literals
26
+
22
27
  import copy
28
+ import operator
23
29
  from itertools import chain
24
30
 
25
31
  from . import message
@@ -112,27 +118,43 @@ in contrast to the other create_type() functions."""
112
118
  return Array(None, bare_utf8, ctype=None, gtype_name=gtype_name,
113
119
  is_const=False)
114
120
 
115
- # Workaround for Gdk.Rectangle being boxed alias for
116
- # cairo.RectangleInt. G-I does not support boxing of aliases.
117
- # See https://bugzilla.gnome.org/show_bug.cgi?id=655423
118
- if gtype_name == 'GdkRectangle':
119
- gtype_name = 'CairoRectangleInt'
120
-
121
121
  return cls(gtype_name=gtype_name)
122
122
 
123
123
  def get_giname(self):
124
124
  assert self.target_giname is not None
125
125
  return self.target_giname.split('.')[1]
126
126
 
127
- def __cmp__(self, other):
127
+ def _compare(self, other, op):
128
128
  if self.target_fundamental:
129
- return cmp(self.target_fundamental, other.target_fundamental)
129
+ return op(self.target_fundamental, other.target_fundamental)
130
130
  elif self.target_giname:
131
- return cmp(self.target_giname, other.target_giname)
131
+ return op(self.target_giname, other.target_giname)
132
132
  elif self.target_foreign:
133
- return cmp(self.target_foreign, other.target_foreign)
133
+ return op(self.target_foreign, other.target_foreign)
134
134
  else:
135
- return cmp(self.ctype, other.ctype)
135
+ return op(self.ctype, other.ctype)
136
+
137
+ def __lt__(self, other):
138
+ return self._compare(other, operator.lt)
139
+
140
+ def __gt__(self, other):
141
+ return self._compare(other, operator.gt)
142
+
143
+ def __ge__(self, other):
144
+ return self._compare(other, operator.ge)
145
+
146
+ def __le__(self, other):
147
+ return self._compare(other, operator.le)
148
+
149
+ def __eq__(self, other):
150
+ return self._compare(other, operator.eq)
151
+
152
+ def __ne__(self, other):
153
+ return self._compare(other, operator.ne)
154
+
155
+ def __hash__(self):
156
+ return hash((self.target_fundamental, self.target_giname,
157
+ self.target_foreign, self.ctype))
136
158
 
137
159
  def is_equiv(self, typeval):
138
160
  """Return True if the specified types are compatible at
@@ -178,13 +200,10 @@ class TypeUnknown(Type):
178
200
  def __init__(self):
179
201
  Type.__init__(self, _target_unknown=True)
180
202
 
181
- ######
182
- ## Fundamental types
183
- ######
184
- # Two special ones
203
+ # Fundamental types, two special ones
185
204
  TYPE_NONE = Type(target_fundamental='none', ctype='void')
186
205
  TYPE_ANY = Type(target_fundamental='gpointer', ctype='gpointer')
187
- # "Basic" types
206
+ # Fundamental types, "Basic" types
188
207
  TYPE_BOOLEAN = Type(target_fundamental='gboolean', ctype='gboolean')
189
208
  TYPE_INT8 = Type(target_fundamental='gint8', ctype='gint8')
190
209
  TYPE_UINT8 = Type(target_fundamental='guint8', ctype='guint8')
@@ -223,13 +242,17 @@ TYPE_FILENAME = Type(target_fundamental='filename', ctype='gchar*')
223
242
 
224
243
  TYPE_VALIST = Type(target_fundamental='va_list', ctype='va_list')
225
244
 
226
- BASIC_GIR_TYPES = [TYPE_BOOLEAN, TYPE_INT8, TYPE_UINT8, TYPE_INT16,
227
- TYPE_UINT16, TYPE_INT32, TYPE_UINT32, TYPE_INT64,
228
- TYPE_UINT64, TYPE_CHAR, TYPE_SHORT, TYPE_USHORT, TYPE_INT,
229
- TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_SIZE, TYPE_SSIZE,
230
- TYPE_LONG_LONG, TYPE_LONG_ULONG, TYPE_INTPTR, TYPE_UINTPTR,
231
- TYPE_FLOAT, TYPE_DOUBLE,
232
- TYPE_LONG_DOUBLE, TYPE_UNICHAR, TYPE_GTYPE]
245
+ BASIC_TYPES = [TYPE_BOOLEAN, TYPE_INT8, TYPE_UINT8, TYPE_INT16,
246
+ TYPE_UINT16, TYPE_INT32, TYPE_UINT32, TYPE_INT64,
247
+ TYPE_UINT64, TYPE_CHAR, TYPE_SHORT, TYPE_USHORT, TYPE_INT,
248
+ TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_SIZE, TYPE_SSIZE,
249
+ TYPE_LONG_LONG, TYPE_LONG_ULONG,
250
+ TYPE_FLOAT, TYPE_DOUBLE,
251
+ TYPE_LONG_DOUBLE, TYPE_UNICHAR, TYPE_GTYPE]
252
+
253
+ BASIC_GIR_TYPES = [TYPE_INTPTR, TYPE_UINTPTR]
254
+ BASIC_GIR_TYPES.extend(BASIC_TYPES)
255
+
233
256
  GIR_TYPES = [TYPE_NONE, TYPE_ANY]
234
257
  GIR_TYPES.extend(BASIC_GIR_TYPES)
235
258
  GIR_TYPES.extend([TYPE_STRING, TYPE_FILENAME, TYPE_VALIST])
@@ -321,6 +344,7 @@ type_names['FILE*'] = TYPE_ANY
321
344
  # the relevant methods, but on the other hand, since these types are just
322
345
  # integers it's easy enough to expand them.
323
346
  type_names['size_t'] = type_names['gsize']
347
+ type_names['ssize_t'] = type_names['gssize']
324
348
  type_names['time_t'] = TYPE_LONG
325
349
  type_names['off_t'] = type_names['gsize']
326
350
  type_names['pid_t'] = TYPE_INT
@@ -328,16 +352,11 @@ type_names['uid_t'] = TYPE_UINT
328
352
  type_names['gid_t'] = TYPE_UINT
329
353
  type_names['dev_t'] = TYPE_INT
330
354
  type_names['socklen_t'] = TYPE_INT32
331
- type_names['size_t'] = TYPE_ULONG
332
- type_names['ssize_t'] = TYPE_LONG
333
355
 
334
356
  # Obj-C
335
357
  type_names['id'] = TYPE_ANY
336
358
 
337
- ##
338
- ## Parameters
339
- ##
340
-
359
+ # Parameters
341
360
  PARAM_DIRECTION_IN = 'in'
342
361
  PARAM_DIRECTION_OUT = 'out'
343
362
  PARAM_DIRECTION_INOUT = 'inout'
@@ -471,11 +490,11 @@ functions via get_by_symbol()."""
471
490
  def __iter__(self):
472
491
  return iter(self.names)
473
492
 
474
- def iteritems(self):
475
- return self.names.iteritems()
493
+ def items(self):
494
+ return self.names.items()
476
495
 
477
- def itervalues(self):
478
- return self.names.itervalues()
496
+ def values(self):
497
+ return self.names.values()
479
498
 
480
499
  def get(self, name):
481
500
  return self.names.get(name)
@@ -487,7 +506,7 @@ functions via get_by_symbol()."""
487
506
  return self.symbols.get(symbol)
488
507
 
489
508
  def walk(self, callback):
490
- for node in self.itervalues():
509
+ for node in self.values():
491
510
  node.walk(callback, [])
492
511
 
493
512
 
@@ -501,11 +520,26 @@ class Include(object):
501
520
  def from_string(cls, string):
502
521
  return cls(*string.split('-', 1))
503
522
 
504
- def __cmp__(self, other):
505
- namecmp = cmp(self.name, other.name)
506
- if namecmp != 0:
507
- return namecmp
508
- return cmp(self.version, other.version)
523
+ def _compare(self, other, op):
524
+ return op((self.name, self.version), (other.name, other.version))
525
+
526
+ def __lt__(self, other):
527
+ return self._compare(other, operator.lt)
528
+
529
+ def __gt__(self, other):
530
+ return self._compare(other, operator.gt)
531
+
532
+ def __ge__(self, other):
533
+ return self._compare(other, operator.ge)
534
+
535
+ def __le__(self, other):
536
+ return self._compare(other, operator.le)
537
+
538
+ def __eq__(self, other):
539
+ return self._compare(other, operator.eq)
540
+
541
+ def __ne__(self, other):
542
+ return self._compare(other, operator.ne)
509
543
 
510
544
  def __hash__(self):
511
545
  return hash(str(self))
@@ -561,14 +595,32 @@ GIName. It's possible for nodes to contain or point to other nodes."""
561
595
  assert self.namespace is not None
562
596
  return Type(target_giname=('%s.%s' % (self.namespace.name, self.name)))
563
597
 
564
- def __cmp__(self, other):
565
- nscmp = cmp(self.namespace, other.namespace)
566
- if nscmp != 0:
567
- return nscmp
568
- return cmp(self.name, other.name)
598
+ def _compare(self, other, op):
599
+ return op((self.namespace, self.name), (other.namespace, other.name))
600
+
601
+ def __lt__(self, other):
602
+ return self._compare(other, operator.lt)
603
+
604
+ def __gt__(self, other):
605
+ return self._compare(other, operator.gt)
606
+
607
+ def __ge__(self, other):
608
+ return self._compare(other, operator.ge)
609
+
610
+ def __le__(self, other):
611
+ return self._compare(other, operator.le)
612
+
613
+ def __eq__(self, other):
614
+ return self._compare(other, operator.eq)
615
+
616
+ def __ne__(self, other):
617
+ return self._compare(other, operator.ne)
618
+
619
+ def __hash__(self):
620
+ return hash((self.namespace, self.name))
569
621
 
570
622
  def __repr__(self):
571
- return '%s(%r)' % (self.__class__.__name__, self.name)
623
+ return "%s('%s')" % (self.__class__.__name__, self.name)
572
624
 
573
625
  def inherit_file_positions(self, node):
574
626
  self.file_positions.update(node.file_positions)
@@ -612,6 +664,34 @@ class Callable(Node):
612
664
  self.instance_parameter = None # Parameter
613
665
  self.parent = None # A Class or Interface
614
666
 
667
+ def _get_retval(self):
668
+ return self._retval
669
+
670
+ def _set_retval(self, value):
671
+ self._retval = value
672
+ if self._retval is not None:
673
+ self._retval.parent = self
674
+ retval = property(_get_retval, _set_retval)
675
+
676
+ def _get_instance_parameter(self):
677
+ return self._instance_parameter
678
+
679
+ def _set_instance_parameter(self, value):
680
+ self._instance_parameter = value
681
+ if value is not None:
682
+ value.parent = self
683
+ instance_parameter = property(_get_instance_parameter,
684
+ _set_instance_parameter)
685
+
686
+ def _get_parameters(self):
687
+ return self._parameters
688
+
689
+ def _set_parameters(self, value):
690
+ self._parameters = value
691
+ for param in self._parameters:
692
+ param.parent = self
693
+ parameters = property(_get_parameters, _set_parameters)
694
+
615
695
  # Returns all parameters, including the instance parameter
616
696
  @property
617
697
  def all_parameters(self):
@@ -650,6 +730,8 @@ class Function(Callable):
650
730
  # copy the parameters array so a change to self.parameters does not
651
731
  # influence clone.parameters.
652
732
  clone.parameters = self.parameters[:]
733
+ for param in clone.parameters:
734
+ param.parent = clone
653
735
  return clone
654
736
 
655
737
  def is_type_meta_function(self):
@@ -763,10 +845,12 @@ class Alias(Node):
763
845
  class TypeContainer(Annotated):
764
846
  """A fundamental base class for Return and Parameter."""
765
847
 
766
- def __init__(self, typenode, nullable, transfer):
848
+ def __init__(self, typenode, nullable, not_nullable, transfer, direction):
767
849
  Annotated.__init__(self)
768
850
  self.type = typenode
769
851
  self.nullable = nullable
852
+ self.not_nullable = not_nullable
853
+ self.direction = direction
770
854
  if transfer is not None:
771
855
  self.transfer = transfer
772
856
  elif typenode.is_const:
@@ -781,11 +865,12 @@ class Parameter(TypeContainer):
781
865
  def __init__(self, argname, typenode, direction=None,
782
866
  transfer=None, nullable=False, optional=False,
783
867
  allow_none=False, scope=None,
784
- caller_allocates=False):
785
- TypeContainer.__init__(self, typenode, nullable, transfer)
868
+ caller_allocates=False, not_nullable=False):
869
+ TypeContainer.__init__(self, typenode, nullable, not_nullable,
870
+ transfer, direction)
786
871
  self.argname = argname
787
- self.direction = direction
788
872
  self.optional = optional
873
+ self.parent = None # A Callable
789
874
 
790
875
  if allow_none:
791
876
  if self.direction == PARAM_DIRECTION_OUT:
@@ -798,13 +883,19 @@ class Parameter(TypeContainer):
798
883
  self.closure_name = None
799
884
  self.destroy_name = None
800
885
 
886
+ @property
887
+ def name(self):
888
+ return self.argname
889
+
801
890
 
802
891
  class Return(TypeContainer):
803
892
  """A return value from a function."""
804
893
 
805
- def __init__(self, rtype, nullable=False, transfer=None):
806
- TypeContainer.__init__(self, rtype, nullable, transfer)
807
- self.direction = PARAM_DIRECTION_OUT
894
+ def __init__(self, rtype, nullable=False, not_nullable=False,
895
+ transfer=None):
896
+ TypeContainer.__init__(self, rtype, nullable, not_nullable, transfer,
897
+ direction=PARAM_DIRECTION_OUT)
898
+ self.parent = None # A Callable
808
899
 
809
900
 
810
901
  class Enum(Node, Registered):
@@ -861,11 +952,32 @@ class Member(Annotated):
861
952
  self.nick = nick
862
953
  self.parent = None
863
954
 
864
- def __cmp__(self, other):
865
- return cmp(self.name, other.name)
955
+ def _compare(self, other, op):
956
+ return op(self.name, other.name)
957
+
958
+ def __lt__(self, other):
959
+ return self._compare(other, operator.lt)
960
+
961
+ def __gt__(self, other):
962
+ return self._compare(other, operator.gt)
963
+
964
+ def __ge__(self, other):
965
+ return self._compare(other, operator.ge)
966
+
967
+ def __le__(self, other):
968
+ return self._compare(other, operator.le)
969
+
970
+ def __eq__(self, other):
971
+ return self._compare(other, operator.eq)
972
+
973
+ def __ne__(self, other):
974
+ return self._compare(other, operator.ne)
975
+
976
+ def __hash__(self):
977
+ return hash(self.name)
866
978
 
867
979
  def __repr__(self):
868
- return '%s(%r)' % (self.__class__.__name__, self.name)
980
+ return "%s('%s')" % (self.__class__.__name__, self.name)
869
981
 
870
982
 
871
983
  class Compound(Node, Registered):
@@ -934,11 +1046,32 @@ class Field(Annotated):
934
1046
  self.namespace = None
935
1047
  self.parent = None # a compound
936
1048
 
937
- def __cmp__(self, other):
938
- return cmp(self.name, other.name)
1049
+ def _compare(self, other, op):
1050
+ return op(self.name, other.name)
1051
+
1052
+ def __lt__(self, other):
1053
+ return self._compare(other, operator.lt)
1054
+
1055
+ def __gt__(self, other):
1056
+ return self._compare(other, operator.gt)
1057
+
1058
+ def __ge__(self, other):
1059
+ return self._compare(other, operator.ge)
1060
+
1061
+ def __le__(self, other):
1062
+ return self._compare(other, operator.le)
1063
+
1064
+ def __eq__(self, other):
1065
+ return self._compare(other, operator.eq)
1066
+
1067
+ def __ne__(self, other):
1068
+ return self._compare(other, operator.ne)
1069
+
1070
+ def __hash__(self):
1071
+ return hash(self.name)
939
1072
 
940
1073
  def __repr__(self):
941
- return '%s(%r)' % (self.__class__.__name__, self.name)
1074
+ return "%s('%s')" % (self.__class__.__name__, self.name)
942
1075
 
943
1076
 
944
1077
  class Record(Compound):
@@ -18,8 +18,12 @@
18
18
  # Boston, MA 02111-1307, USA.
19
19
  #
20
20
 
21
+ from __future__ import absolute_import
22
+ from __future__ import division
23
+ from __future__ import print_function
24
+ from __future__ import unicode_literals
25
+
21
26
  import errno
22
- import cPickle
23
27
  import glob
24
28
  import hashlib
25
29
  import os
@@ -27,61 +31,42 @@ import shutil
27
31
  import sys
28
32
  import tempfile
29
33
 
34
+ try:
35
+ import cPickle as pickle
36
+ except ImportError:
37
+ import pickle
38
+
30
39
  import giscanner
31
40
 
41
+ from . import utils
42
+
43
+
32
44
  _CACHE_VERSION_FILENAME = '.cache-version'
33
45
 
34
46
 
35
47
  def _get_versionhash():
36
48
  toplevel = os.path.dirname(giscanner.__file__)
37
- # Use pyc instead of py to avoid extra IO
38
- sources = glob.glob(os.path.join(toplevel, '*.pyc'))
49
+ sources = glob.glob(os.path.join(toplevel, '*.py'))
39
50
  sources.append(sys.argv[0])
40
51
  # Using mtimes is a bit (5x) faster than hashing the file contents
41
52
  mtimes = (str(os.stat(source).st_mtime) for source in sources)
42
- return hashlib.sha1(''.join(mtimes)).hexdigest()
43
-
44
-
45
- def _get_cachedir():
46
- if 'GI_SCANNER_DISABLE_CACHE' in os.environ:
47
- return None
48
- homedir = os.path.expanduser('~')
49
- if homedir is None:
50
- return None
51
- if not os.path.exists(homedir):
52
- return None
53
-
54
- cachedir = os.path.join(homedir, '.cache')
55
- if not os.path.exists(cachedir):
56
- try:
57
- os.mkdir(cachedir, 0o755)
58
- except OSError:
59
- return None
60
-
61
- scannerdir = os.path.join(cachedir, 'g-ir-scanner')
62
- if not os.path.exists(scannerdir):
63
- try:
64
- os.mkdir(scannerdir, 0o755)
65
- except OSError:
66
- return None
67
- # If it exists and is a file, don't cache at all
68
- elif not os.path.isdir(scannerdir):
69
- return None
70
- return scannerdir
53
+ # ASCII encoding is sufficient since we are only dealing with numbers.
54
+ return hashlib.sha1(''.join(mtimes).encode('ascii')).hexdigest()
71
55
 
72
56
 
73
57
  class CacheStore(object):
74
58
 
75
59
  def __init__(self):
76
- try:
77
- self._directory = _get_cachedir()
78
- except OSError as e:
79
- if e.errno != errno.EPERM:
80
- raise
81
- self._directory = None
82
-
60
+ self._directory = self._get_cachedir()
83
61
  self._check_cache_version()
84
62
 
63
+ def _get_cachedir(self):
64
+ if 'GI_SCANNER_DISABLE_CACHE' in os.environ:
65
+ return None
66
+ else:
67
+ cachedir = utils.get_user_cache_dir('g-ir-scanner')
68
+ return cachedir
69
+
85
70
  def _check_cache_version(self):
86
71
  if self._directory is None:
87
72
  return
@@ -89,7 +74,8 @@ class CacheStore(object):
89
74
  current_hash = _get_versionhash()
90
75
  version = os.path.join(self._directory, _CACHE_VERSION_FILENAME)
91
76
  try:
92
- cache_hash = open(version).read()
77
+ with open(version, 'r') as version_file:
78
+ cache_hash = version_file.read()
93
79
  except IOError as e:
94
80
  # File does not exist
95
81
  if e.errno == errno.ENOENT:
@@ -100,11 +86,16 @@ class CacheStore(object):
100
86
  if current_hash == cache_hash:
101
87
  return
102
88
 
103
- versiontmp = version + '.tmp'
104
-
105
89
  self._clean()
90
+
91
+ tmp_fd, tmp_filename = tempfile.mkstemp(prefix='g-ir-scanner-cache-version-')
106
92
  try:
107
- fp = open(versiontmp, 'w')
93
+ with os.fdopen(tmp_fd, 'w') as tmp_file:
94
+ tmp_file.write(current_hash)
95
+
96
+ # On Unix, this would just be os.rename() but Windows
97
+ # doesn't allow that.
98
+ shutil.move(tmp_filename, version)
108
99
  except IOError as e:
109
100
  # Permission denied
110
101
  if e.errno == errno.EACCES:
@@ -112,19 +103,15 @@ class CacheStore(object):
112
103
  else:
113
104
  raise
114
105
 
115
- fp.write(current_hash)
116
- fp.close()
117
- # On Unix, this would just be os.rename() but Windows
118
- # doesn't allow that.
119
- shutil.move(versiontmp, version)
120
-
121
106
  def _get_filename(self, filename):
122
107
  # If we couldn't create the directory we're probably
123
108
  # on a read only home directory where we just disable
124
109
  # the cache all together.
125
110
  if self._directory is None:
126
111
  return
127
- hexdigest = hashlib.sha1(filename).hexdigest()
112
+ # Assume UTF-8 encoding for the filenames. This doesn't matter so much
113
+ # as long as the results of this method always produce the same hash.
114
+ hexdigest = hashlib.sha1(filename.encode('utf-8')).hexdigest()
128
115
  return os.path.join(self._directory, hexdigest)
129
116
 
130
117
  def _cache_is_valid(self, store_filename, filename):
@@ -163,7 +150,8 @@ class CacheStore(object):
163
150
 
164
151
  tmp_fd, tmp_filename = tempfile.mkstemp(prefix='g-ir-scanner-cache-')
165
152
  try:
166
- cPickle.dump(data, os.fdopen(tmp_fd, 'w'))
153
+ with os.fdopen(tmp_fd, 'wb') as tmp_file:
154
+ pickle.dump(data, tmp_file)
167
155
  except IOError as e:
168
156
  # No space left on device
169
157
  if e.errno == errno.ENOSPC:
@@ -186,7 +174,7 @@ class CacheStore(object):
186
174
  if store_filename is None:
187
175
  return
188
176
  try:
189
- fd = open(store_filename)
177
+ fd = open(store_filename, 'rb')
190
178
  except IOError as e:
191
179
  if e.errno == errno.ENOENT:
192
180
  return None
@@ -195,8 +183,8 @@ class CacheStore(object):
195
183
  if not self._cache_is_valid(store_filename, filename):
196
184
  return None
197
185
  try:
198
- data = cPickle.load(fd)
199
- except (AttributeError, EOFError, ValueError, cPickle.BadPickleGet):
186
+ data = pickle.load(fd)
187
+ except (AttributeError, EOFError, ValueError, pickle.BadPickleGet):
200
188
  # Broken cache entry, remove it
201
189
  self._remove_filename(store_filename)
202
190
  data = None