[gobject-introspection] giscanner: make Annotated.attributes an OrderedDict



commit 2f8d00d6474cc946f5f346eaa832eaf0f09a6f0a
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Mon Aug 12 07:10:08 2013 +0200

    giscanner: make Annotated.attributes an OrderedDict
    
    annotationparser.py already stores attributes in a mapping so
    it makes little sense using a list of tuples (suggesting
    multiple duplicate keys would be allowed) on the ast side.

 giscanner/ast.py             |    2 +-
 giscanner/girwriter.py       |    2 +-
 giscanner/maintransformer.py |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/giscanner/ast.py b/giscanner/ast.py
index becc126..a30a6a7 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -516,7 +516,7 @@ properties."""
         self.version_doc = None
         self.skip = False
         self.introspectable = True
-        self.attributes = []    # (key, value)*
+        self.attributes = OrderedDict()
         self.stability = None
         self.stability_doc = None
         self.deprecated = None
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index e5841ec..2bc9f15 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -123,7 +123,7 @@ class GIRWriter(XMLWriter):
             attrs.append(('version', node.version))
 
     def _write_generic(self, node):
-        for key, value in node.attributes:
+        for key, value in node.attributes.items():
             self.write_tag('attribute', [('name', key), ('value', value)])
 
         if hasattr(node, 'doc') and node.doc:
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 8de9616..92a0773 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -576,7 +576,7 @@ class MainTransformer(object):
             if attributes_annotation is not None:
                 for key, value in attributes_annotation.items():
                     if value:
-                        node.attributes.append((key, value))
+                        node.attributes[key] = value
 
     def _apply_annotations_annotated(self, node, block):
         if block is None:
@@ -610,7 +610,7 @@ class MainTransformer(object):
         if attributes_annotation is not None:
             for key, value in attributes_annotation.items():
                 if value:
-                    node.attributes.append((key, value))
+                    node.attributes[key] = value
 
         if ANN_SKIP in block.annotations:
             node.skip = True


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]