gobject-introspection 2.2.0-x86-mingw32 → 2.2.1-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 (176) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -7
  3. data/ext/gobject-introspection/rb-gi-argument.c +28 -3
  4. data/ext/gobject-introspection/rb-gi-constructor-info.c +6 -1
  5. data/ext/gobject-introspection/rb-gi-function-info.c +29 -4
  6. data/ext/gobject-introspection/rb-gi-loader.c +19 -3
  7. data/ext/gobject-introspection/rb-gi-struct-info.c +28 -16
  8. data/lib/2.0/gobject_introspection.so +0 -0
  9. data/lib/gobject-introspection/callable-info.rb +16 -7
  10. data/lib/gobject-introspection/loader.rb +47 -19
  11. data/test/test-object-info.rb +1 -1
  12. data/test/test-signal-info.rb +2 -2
  13. data/test/test-struct-info.rb +1 -1
  14. data/vendor/local/bin/g-ir-compiler.exe +0 -0
  15. data/vendor/local/bin/g-ir-generate.exe +0 -0
  16. data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
  17. data/vendor/local/include/gobject-introspection-1.0/giarginfo.h +30 -0
  18. data/vendor/local/include/gobject-introspection-1.0/gibaseinfo.h +31 -0
  19. data/vendor/local/include/gobject-introspection-1.0/gicallableinfo.h +36 -0
  20. data/vendor/local/include/gobject-introspection-1.0/giconstantinfo.h +12 -0
  21. data/vendor/local/include/gobject-introspection-1.0/gienuminfo.h +26 -0
  22. data/vendor/local/include/gobject-introspection-1.0/gifieldinfo.h +19 -0
  23. data/vendor/local/include/gobject-introspection-1.0/gifunctioninfo.h +23 -0
  24. data/vendor/local/include/gobject-introspection-1.0/giinterfaceinfo.h +38 -0
  25. data/vendor/local/include/gobject-introspection-1.0/giobjectinfo.h +72 -2
  26. data/vendor/local/include/gobject-introspection-1.0/gipropertyinfo.h +12 -0
  27. data/vendor/local/include/gobject-introspection-1.0/giregisteredtypeinfo.h +11 -0
  28. data/vendor/local/include/gobject-introspection-1.0/girepository.h +68 -8
  29. data/vendor/local/include/gobject-introspection-1.0/girffi.h +25 -1
  30. data/vendor/local/include/gobject-introspection-1.0/gisignalinfo.h +12 -0
  31. data/vendor/local/include/gobject-introspection-1.0/gistructinfo.h +24 -0
  32. data/vendor/local/include/gobject-introspection-1.0/gitypeinfo.h +31 -0
  33. data/vendor/local/include/gobject-introspection-1.0/gitypelib.h +25 -0
  34. data/vendor/local/include/gobject-introspection-1.0/gitypes.h +84 -13
  35. data/vendor/local/include/gobject-introspection-1.0/giunioninfo.h +27 -0
  36. data/vendor/local/include/gobject-introspection-1.0/giversionmacros.h +128 -0
  37. data/vendor/local/include/gobject-introspection-1.0/givfuncinfo.h +17 -0
  38. data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
  39. data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
  40. data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
  41. data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
  42. data/vendor/local/lib/girepository-1.0/libxml2-2.0.typelib +0 -0
  43. data/vendor/local/lib/girepository-1.0/win32-1.0.typelib +0 -0
  44. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
  45. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
  46. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.py +5 -4
  47. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
  48. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
  49. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +1865 -913
  50. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
  51. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
  52. data/vendor/local/lib/gobject-introspection/giscanner/ast.py +49 -16
  53. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
  54. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
  55. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.py +10 -4
  56. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
  57. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
  58. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.py +202 -0
  59. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyc +0 -0
  60. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyo +0 -0
  61. data/vendor/local/lib/gobject-introspection/giscanner/codegen.py +32 -1
  62. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
  63. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
  64. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.py +1 -0
  65. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyc +0 -0
  66. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyo +0 -0
  67. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.py +305 -0
  68. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyc +0 -0
  69. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyo +0 -0
  70. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyc +0 -0
  71. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyo +0 -0
  72. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
  73. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
  74. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/callback.tmpl +4 -0
  75. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/field.tmpl +1 -0
  76. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/function.tmpl +8 -9
  77. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/interface.tmpl +2 -0
  78. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/callback.tmpl +27 -0
  79. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/class.tmpl +17 -5
  80. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/enum.tmpl +8 -0
  81. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/field.tmpl +9 -0
  82. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/function.tmpl +12 -13
  83. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/interface.tmpl +17 -0
  84. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/property.tmpl +3 -4
  85. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/signal.tmpl +10 -9
  86. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/vfunc.tmpl +7 -7
  87. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/callback.tmpl +27 -0
  88. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/class.tmpl +5 -4
  89. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/field.tmpl +1 -0
  90. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/function.tmpl +8 -14
  91. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/interface.tmpl +16 -0
  92. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/property.tmpl +2 -3
  93. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/signal.tmpl +6 -7
  94. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/vfunc.tmpl +7 -13
  95. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/base.tmpl +10 -19
  96. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/class.tmpl +24 -3
  97. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/namespace.tmpl +4 -7
  98. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.py +375 -61
  99. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
  100. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
  101. data/vendor/local/lib/gobject-introspection/giscanner/dumper.py +43 -75
  102. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
  103. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
  104. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.py +1 -20
  105. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
  106. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
  107. data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +33 -15
  108. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
  109. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
  110. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.py +51 -22
  111. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
  112. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
  113. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
  114. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
  115. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
  116. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
  117. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +285 -254
  118. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
  119. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
  120. data/vendor/local/lib/gobject-introspection/giscanner/message.py +41 -25
  121. data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
  122. data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
  123. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +67 -15
  124. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
  125. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
  126. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
  127. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
  128. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.py +10 -6
  129. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
  130. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
  131. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +14 -8
  132. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
  133. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
  134. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.py +16 -2
  135. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
  136. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
  137. data/vendor/local/lib/gobject-introspection/giscanner/transformer.py +150 -169
  138. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
  139. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
  140. data/vendor/local/lib/gobject-introspection/giscanner/utils.py +64 -3
  141. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
  142. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
  143. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.py +5 -44
  144. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
  145. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
  146. data/vendor/local/lib/libgirepository-1.0.a +0 -0
  147. data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
  148. data/vendor/local/lib/libgirepository-1.0.la +1 -1
  149. data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +4 -4
  150. data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +5 -5
  151. data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +352 -143
  152. data/vendor/local/share/gir-1.0/GLib-2.0.gir +6402 -3872
  153. data/vendor/local/share/gir-1.0/GModule-2.0.gir +42 -24
  154. data/vendor/local/share/gir-1.0/GObject-2.0.gir +1543 -887
  155. data/vendor/local/share/gir-1.0/Gio-2.0.gir +10859 -3705
  156. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.c +10 -14
  157. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.h +112 -9
  158. data/vendor/local/share/gobject-introspection-1.0/tests/drawable.c +2 -0
  159. data/vendor/local/share/gobject-introspection-1.0/tests/drawable.h +11 -0
  160. data/vendor/local/share/gobject-introspection-1.0/tests/everything.c +106 -0
  161. data/vendor/local/share/gobject-introspection-1.0/tests/everything.h +107 -0
  162. data/vendor/local/share/gobject-introspection-1.0/tests/foo.c +3 -3
  163. data/vendor/local/share/gobject-introspection-1.0/tests/foo.h +145 -0
  164. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +166 -10
  165. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.h +790 -0
  166. data/vendor/local/share/gobject-introspection-1.0/tests/gitestmacros.h +10 -0
  167. data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +79 -28
  168. data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +462 -0
  169. data/vendor/local/share/gobject-introspection-1.0/tests/utility.c +2 -0
  170. data/vendor/local/share/gobject-introspection-1.0/tests/utility.h +7 -0
  171. data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.c +14 -0
  172. data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.h +10 -0
  173. data/vendor/local/share/man/man1/g-ir-compiler.1 +1 -10
  174. metadata +38 -23
  175. data/lib/1.9/gobject_introspection.so +0 -0
  176. data/lib/2.1/gobject_introspection.so +0 -0
@@ -409,12 +409,15 @@ but adds it to things like ctypes, symbols, and type_names.
409
409
  self.type_names[node.gtype_name] = node
410
410
  elif isinstance(node, Function):
411
411
  self.symbols[node.symbol] = node
412
- if isinstance(node, (Compound, Class, Interface)):
412
+ if isinstance(node, (Compound, Class, Interface, Boxed)):
413
413
  for fn in chain(node.methods, node.static_methods, node.constructors):
414
414
  if not isinstance(fn, Function):
415
415
  continue
416
416
  fn.namespace = self
417
417
  self.symbols[fn.symbol] = fn
418
+ if isinstance(node, (Compound, Class, Interface)):
419
+ for f in node.fields:
420
+ f.namespace = self
418
421
  if isinstance(node, (Class, Interface)):
419
422
  for m in chain(node.signals, node.properties):
420
423
  m.namespace = self
@@ -513,12 +516,14 @@ class Annotated(object):
513
516
  properties."""
514
517
  def __init__(self):
515
518
  self.version = None
519
+ self.version_doc = None
516
520
  self.skip = False
517
521
  self.introspectable = True
518
- self.attributes = [] # (key, value)*
522
+ self.attributes = OrderedDict()
519
523
  self.stability = None
524
+ self.stability_doc = None
520
525
  self.deprecated = None
521
- self.deprecated_version = None
526
+ self.deprecated_doc = None
522
527
  self.doc = None
523
528
 
524
529
 
@@ -676,8 +681,8 @@ class VFunction(Callable):
676
681
  self.invoker = None
677
682
 
678
683
  @classmethod
679
- def from_callback(cls, cb):
680
- obj = cls(cb.name, cb.retval, cb.parameters[1:],
684
+ def from_callback(cls, name, cb):
685
+ obj = cls(name, cb.retval, cb.parameters[1:],
681
686
  cb.throws)
682
687
  return obj
683
688
 
@@ -755,9 +760,10 @@ class Alias(Node):
755
760
  class TypeContainer(Annotated):
756
761
  """A fundamental base class for Return and Parameter."""
757
762
 
758
- def __init__(self, typenode, transfer):
763
+ def __init__(self, typenode, nullable, transfer):
759
764
  Annotated.__init__(self)
760
765
  self.type = typenode
766
+ self.nullable = nullable
761
767
  if transfer is not None:
762
768
  self.transfer = transfer
763
769
  elif typenode.is_const:
@@ -770,12 +776,20 @@ class Parameter(TypeContainer):
770
776
  """An argument to a function."""
771
777
 
772
778
  def __init__(self, argname, typenode, direction=None,
773
- transfer=None, allow_none=False, scope=None,
779
+ transfer=None, nullable=False, optional=False,
780
+ allow_none=False, scope=None,
774
781
  caller_allocates=False):
775
- TypeContainer.__init__(self, typenode, transfer)
782
+ TypeContainer.__init__(self, typenode, nullable, transfer)
776
783
  self.argname = argname
777
784
  self.direction = direction
778
- self.allow_none = allow_none
785
+ self.optional = optional
786
+
787
+ if allow_none:
788
+ if self.direction == PARAM_DIRECTION_OUT:
789
+ self.optional = True
790
+ else:
791
+ self.nullable = True
792
+
779
793
  self.scope = scope
780
794
  self.caller_allocates = caller_allocates
781
795
  self.closure_name = None
@@ -785,8 +799,8 @@ class Parameter(TypeContainer):
785
799
  class Return(TypeContainer):
786
800
  """A return value from a function."""
787
801
 
788
- def __init__(self, rtype, transfer=None):
789
- TypeContainer.__init__(self, rtype, transfer)
802
+ def __init__(self, rtype, nullable=False, transfer=None):
803
+ TypeContainer.__init__(self, rtype, nullable, transfer)
790
804
  self.direction = PARAM_DIRECTION_OUT
791
805
 
792
806
 
@@ -857,7 +871,8 @@ class Compound(Node, Registered):
857
871
  gtype_name=None,
858
872
  get_type=None,
859
873
  c_symbol_prefix=None,
860
- disguised=False):
874
+ disguised=False,
875
+ tag_name=None):
861
876
  Node.__init__(self, name)
862
877
  Registered.__init__(self, gtype_name, get_type)
863
878
  self.ctype = ctype
@@ -869,6 +884,7 @@ class Compound(Node, Registered):
869
884
  self.gtype_name = gtype_name
870
885
  self.get_type = get_type
871
886
  self.c_symbol_prefix = c_symbol_prefix
887
+ self.tag_name = tag_name
872
888
 
873
889
  def add_gtype(self, gtype_name, get_type):
874
890
  self.gtype_name = gtype_name
@@ -886,6 +902,18 @@ class Compound(Node, Registered):
886
902
  if field.anonymous_node is not None:
887
903
  field.anonymous_node.walk(callback, chain)
888
904
 
905
+ def get_field(self, name):
906
+ for field in self.fields:
907
+ if field.name == name:
908
+ return field
909
+ raise ValueError("Unknown field %s" % (name, ))
910
+
911
+ def get_field_index(self, name):
912
+ for i, field in enumerate(self.fields):
913
+ if field.name == name:
914
+ return i
915
+ raise ValueError("Unknown field %s" % (name, ))
916
+
889
917
 
890
918
  class Field(Annotated):
891
919
 
@@ -900,6 +928,7 @@ class Field(Annotated):
900
928
  self.bits = bits
901
929
  self.anonymous_node = anonymous_node
902
930
  self.private = False
931
+ self.namespace = None
903
932
  self.parent = None # a compound
904
933
 
905
934
  def __cmp__(self, other):
@@ -916,13 +945,15 @@ class Record(Compound):
916
945
  gtype_name=None,
917
946
  get_type=None,
918
947
  c_symbol_prefix=None,
919
- disguised=False):
948
+ disguised=False,
949
+ tag_name=None):
920
950
  Compound.__init__(self, name,
921
951
  ctype=ctype,
922
952
  gtype_name=gtype_name,
923
953
  get_type=get_type,
924
954
  c_symbol_prefix=c_symbol_prefix,
925
- disguised=disguised)
955
+ disguised=disguised,
956
+ tag_name=tag_name)
926
957
  # If non-None, this record defines the FooClass C structure
927
958
  # for some Foo GObject (or similar for GInterface)
928
959
  self.is_gtype_struct_for = None
@@ -935,13 +966,15 @@ class Union(Compound):
935
966
  gtype_name=None,
936
967
  get_type=None,
937
968
  c_symbol_prefix=None,
938
- disguised=False):
969
+ disguised=False,
970
+ tag_name=None):
939
971
  Compound.__init__(self, name,
940
972
  ctype=ctype,
941
973
  gtype_name=gtype_name,
942
974
  get_type=get_type,
943
975
  c_symbol_prefix=c_symbol_prefix,
944
- disguised=disguised)
976
+ disguised=disguised,
977
+ tag_name=tag_name)
945
978
 
946
979
 
947
980
  class Boxed(Node, Registered):
@@ -45,7 +45,7 @@ def _get_versionhash():
45
45
  def _get_cachedir():
46
46
  if 'GI_SCANNER_DISABLE_CACHE' in os.environ:
47
47
  return None
48
- homedir = os.environ.get('HOME')
48
+ homedir = os.path.expanduser('~')
49
49
  if homedir is None:
50
50
  return None
51
51
  if not os.path.exists(homedir):
@@ -54,14 +54,14 @@ def _get_cachedir():
54
54
  cachedir = os.path.join(homedir, '.cache')
55
55
  if not os.path.exists(cachedir):
56
56
  try:
57
- os.mkdir(cachedir, 0755)
57
+ os.mkdir(cachedir, 0o755)
58
58
  except OSError:
59
59
  return None
60
60
 
61
61
  scannerdir = os.path.join(cachedir, 'g-ir-scanner')
62
62
  if not os.path.exists(scannerdir):
63
63
  try:
64
- os.mkdir(scannerdir, 0755)
64
+ os.mkdir(scannerdir, 0o755)
65
65
  except OSError:
66
66
  return None
67
67
  # If it exists and is a file, don't cache at all
@@ -100,9 +100,11 @@ class CacheStore(object):
100
100
  if current_hash == cache_hash:
101
101
  return
102
102
 
103
+ versiontmp = version + '.tmp'
104
+
103
105
  self._clean()
104
106
  try:
105
- fp = open(version, 'w')
107
+ fp = open(versiontmp, 'w')
106
108
  except IOError as e:
107
109
  # Permission denied
108
110
  if e.errno == errno.EACCES:
@@ -111,6 +113,10 @@ class CacheStore(object):
111
113
  raise
112
114
 
113
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)
114
120
 
115
121
  def _get_filename(self, filename):
116
122
  # If we couldn't create the directory we're probably
@@ -0,0 +1,202 @@
1
+ # -*- Mode: Python -*-
2
+ # GObject-Introspection - a framework for introspecting GObject libraries
3
+ # Copyright (C) 2014 Chun-wei Fan
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the
17
+ # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
+ # Boston, MA 02111-1307, USA.
19
+ #
20
+
21
+ import os
22
+ import subprocess
23
+ import sys
24
+ import distutils
25
+
26
+ from distutils.msvccompiler import MSVCCompiler
27
+ from distutils.cygwinccompiler import Mingw32CCompiler
28
+ from distutils.sysconfig import customize_compiler
29
+
30
+ from . import utils
31
+
32
+
33
+ class CCompiler(object):
34
+
35
+ compiler_cmd = ''
36
+ compiler = None
37
+ _cflags_no_deprecation_warnings = ''
38
+
39
+ def __init__(self, compiler_name=None):
40
+ pass
41
+
42
+ def get_internal_link_flags(self,
43
+ args,
44
+ libtool,
45
+ libraries,
46
+ libpaths,
47
+ pkgconfig_msvc_flags,
48
+ ns,
49
+ ns_version):
50
+ # An "internal" link is where the library to be introspected
51
+ # is being built in the current directory.
52
+
53
+ # Search the current directory first
54
+ # (This flag is not supported nor needed for Visual C++)
55
+ if pkgconfig_msvc_flags == '':
56
+ args.append('-L.')
57
+
58
+ # https://bugzilla.gnome.org/show_bug.cgi?id=625195
59
+ if not libtool:
60
+ # We don't have -Wl,-rpath for Visual C++, and that's
61
+ # going to cause a problem. Instead, link to internal
62
+ # libraries by deducing the .lib file name using
63
+ # the namespace name and version
64
+ if pkgconfig_msvc_flags:
65
+ if ns_version:
66
+ args.append(str.lower(ns) +
67
+ '-' +
68
+ ns_version + '.lib')
69
+ else:
70
+ args.append(str.lower(ns) + '.lib')
71
+ else:
72
+ args.append('-Wl,-rpath=.')
73
+
74
+ # Ensure libraries are always linked as we are going to use ldd to work
75
+ # out their names later
76
+ if not libtool and pkgconfig_msvc_flags == '':
77
+ args.append('-Wl,--no-as-needed')
78
+
79
+ for library in libraries:
80
+ # Visual C++: We have the needed .lib files now, and we need to link
81
+ # to .lib files, not the .dll as the --library option specifies the
82
+ # .dll(s) the .gir file refers to
83
+ if pkgconfig_msvc_flags == '':
84
+ if library.endswith(".la"): # explicitly specified libtool library
85
+ args.append(library)
86
+ else:
87
+ args.append('-l' + library)
88
+
89
+ for library_path in libpaths:
90
+ # Not used/needed on Visual C++, and -Wl,-rpath options
91
+ # will cause grief
92
+ if pkgconfig_msvc_flags == '':
93
+ args.append('-L' + library_path)
94
+ if os.path.isabs(library_path):
95
+ if libtool:
96
+ args.append('-rpath')
97
+ args.append(library_path)
98
+ else:
99
+ args.append('-Wl,-rpath=' + library_path)
100
+
101
+ def get_external_link_flags(self, args, libraries, pkgconfig_msvc_flags):
102
+ # An "external" link is where the library to be introspected
103
+ # is installed on the system; this case is used for the scanning
104
+ # of GLib in gobject-introspection itself.
105
+
106
+ for library in libraries:
107
+ # The --library option on Windows pass in the .dll file(s) the
108
+ # .gir files refer to, so don't link to them on Visual C++
109
+ if pkgconfig_msvc_flags == '':
110
+ if library.endswith(".la"): # explicitly specified libtool library
111
+ args.append(library)
112
+ else:
113
+ args.append('-l' + library)
114
+
115
+ def resolve_windows_libs(self, libraries, options):
116
+ args = []
117
+ compiler_cmd = os.environ.get('CC', 'cc')
118
+ libsearch = []
119
+
120
+ # When we are using Visual C++...
121
+ if 'cl.exe' in compiler_cmd or 'cl' in compiler_cmd:
122
+ # The search path of the .lib's on Visual C++
123
+ # is dependent on the LIB environmental variable,
124
+ # so just query for that
125
+ is_msvc = True
126
+ libpath = os.environ.get('LIB')
127
+ libsearch = libpath.split(';')
128
+
129
+ # Use the dumpbin utility that's included in
130
+ # every Visual C++ installation to find out which
131
+ # DLL the library gets linked to
132
+ args.append('dumpbin.exe')
133
+ args.append('-symbols')
134
+
135
+ # When we are not using Visual C++ (i.e. we are using GCC)...
136
+ else:
137
+ is_msvc = False
138
+ libtool = utils.get_libtool_command(options)
139
+ if libtool:
140
+ args.append(utils.which(os.environ.get('SHELL', 'sh.exe')))
141
+ args.extend(libtool)
142
+ args.append('--mode=execute')
143
+ # FIXME: it could have prefix (i686-w64-mingw32-dlltool.exe)
144
+ args.extend(['dlltool.exe', '--identify'])
145
+ proc = subprocess.Popen([compiler_cmd, '-print-search-dirs'],
146
+ stdout=subprocess.PIPE)
147
+ o, e = proc.communicate()
148
+ for line in o.splitlines():
149
+ if line.startswith('libraries: '):
150
+ libsearch = line[len('libraries: '):].split(';')
151
+
152
+ shlibs = []
153
+ not_resolved = []
154
+ for lib in libraries:
155
+ found = False
156
+ candidates = [
157
+ 'lib%s.dll.a' % lib,
158
+ 'lib%s.a' % lib,
159
+ '%s.dll.a' % lib,
160
+ '%s.a' % lib,
161
+ '%s.lib' % lib,
162
+ ]
163
+ for l in libsearch:
164
+ if found:
165
+ break
166
+ if l.startswith('='):
167
+ l = l[1:]
168
+ for c in candidates:
169
+ if found:
170
+ break
171
+ implib = os.path.join(l, c)
172
+ if os.path.exists(implib):
173
+ proc = subprocess.Popen(args + [implib],
174
+ stdout=subprocess.PIPE)
175
+ o, e = proc.communicate()
176
+ for line in o.splitlines():
177
+ if is_msvc:
178
+ # On Visual Studio, dumpbin -symbols something.lib gives the
179
+ # filename of DLL without the '.dll' extension that something.lib
180
+ # links to, in the line that contains
181
+ # __IMPORT_DESCRIPTOR_<dll_filename_that_something.lib_links_to>
182
+
183
+ if '__IMPORT_DESCRIPTOR_' in line:
184
+ line_tokens = line.split()
185
+ for item in line_tokens:
186
+ if item.startswith('__IMPORT_DESCRIPTOR_'):
187
+ shlibs.append(item[20:] + '.dll')
188
+ found = True
189
+ break
190
+ if found:
191
+ break
192
+ else:
193
+ shlibs.append(line)
194
+ found = True
195
+ break
196
+ if not found:
197
+ not_resolved.append(lib)
198
+ if len(not_resolved) > 0:
199
+ raise SystemExit(
200
+ "ERROR: can't resolve libraries to shared libraries: " +
201
+ ", ".join(not_resolved))
202
+ return shlibs
@@ -26,9 +26,21 @@ from . import ast
26
26
 
27
27
 
28
28
  class CCodeGenerator(object):
29
- def __init__(self, namespace, out_h_filename, out_c_filename):
29
+ def __init__(self, namespace,
30
+ out_h_filename,
31
+ out_c_filename,
32
+ function_decoration=[],
33
+ include_first_header=[],
34
+ include_last_header=[],
35
+ include_first_src=[],
36
+ include_last_src=[]):
30
37
  self.out_h_filename = out_h_filename
31
38
  self.out_c_filename = out_c_filename
39
+ self.function_decoration = function_decoration
40
+ self.include_first_header = include_first_header
41
+ self.include_last_header = include_last_header
42
+ self.include_first_src = include_first_src
43
+ self.include_last_src = include_last_src
32
44
  self._function_bodies = {}
33
45
  self.namespace = namespace
34
46
 
@@ -50,6 +62,10 @@ class CCodeGenerator(object):
50
62
  return param.type.ctype + suffix
51
63
 
52
64
  def _write_prelude(self, out, func):
65
+ if self.function_decoration:
66
+ out.write("""
67
+ %s""" % " ".join(self.function_decoration))
68
+
53
69
  out.write("""
54
70
  %s
55
71
  %s (""" % (self._typecontainer_to_ctype(func.retval), func.symbol))
@@ -105,16 +121,31 @@ class CCodeGenerator(object):
105
121
  warning = '/* GENERATED BY testcodegen.py; DO NOT EDIT */\n\n'
106
122
  self.out_h.write(warning)
107
123
  nsupper = self.namespace.name.upper()
124
+
125
+ for header in self.include_first_header:
126
+ self.out_h.write("""#include "%s"\n""" % header)
127
+
108
128
  self.out_h.write("""
109
129
  #ifndef __%s_H__
110
130
  #define __%s_H__
111
131
 
112
132
  #include <glib-object.h>
133
+
113
134
  """ % (nsupper, nsupper))
114
135
 
136
+ for header in self.include_last_header:
137
+ self.out_h.write("""#include "%s"\n""" % header)
138
+
115
139
  self.out_c.write(warning)
140
+
141
+ for header in self.include_first_src:
142
+ self.out_c.write("""#include "%s"\n""" % header)
143
+
116
144
  self.out_c.write("""#include "%s"\n\n""" % (self.out_h_filename, ))
117
145
 
146
+ for header in self.include_last_src:
147
+ self.out_c.write("""#include "%s"\n""" % header)
148
+
118
149
  def _codegen_end(self):
119
150
  self.out_h.write("""#endif\n""")
120
151
 
@@ -19,4 +19,5 @@
19
19
  #
20
20
 
21
21
 
22
+ from .counter import Counter
22
23
  from .ordereddict import OrderedDict