[glib/mcatanzaro/glib-2-56-rhel8] codegen: Support Since and name changing annotations on annotations



commit fe823e3cfe25c96de5e453d1acbdc036892a9c36
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Apr 17 14:07:50 2018 +0100

    codegen: Support Since and name changing annotations on annotations
    
    Recursive annotations do seem to be supported, so we should support them
    properly in the type system representation. This currently introduces no
    behavioural changes, but will be used in upcoming commits.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=795304

 gio/gdbus-2.0/codegen/dbustypes.py | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
---
diff --git a/gio/gdbus-2.0/codegen/dbustypes.py b/gio/gdbus-2.0/codegen/dbustypes.py
index 359880ff70..29222f987f 100644
--- a/gio/gdbus-2.0/codegen/dbustypes.py
+++ b/gio/gdbus-2.0/codegen/dbustypes.py
@@ -27,6 +27,25 @@ class Annotation:
         self.key = key
         self.value = value
         self.annotations = []
+        self.since = ''
+
+    def post_process(self, interface_prefix, cns, cns_upper, cns_lower, container):
+        key = self.key
+        overridden_key = utils.lookup_annotation(self.annotations, 'org.gtk.GDBus.C.Name')
+        if utils.is_ugly_case(overridden_key):
+            self.key_lower = overridden_key.lower()
+        else:
+            if overridden_key:
+                key = overridden_key
+            self.key_lower = utils.camel_case_to_uscore(key).lower().replace('-', '_').replace('.', '_')
+
+        if len(self.since) == 0:
+            self.since = utils.lookup_since(self.annotations)
+            if len(self.since) == 0:
+                self.since = container.since
+
+        for a in self.annotations:
+            a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
 
 class Arg:
     def __init__(self, name, signature):
@@ -229,6 +248,8 @@ class Arg:
                 self.gvalue_get = 'g_value_get_boxed'
                 self.array_annotation = '(array zero-terminated=1)'
 
+        for a in self.annotations:
+            a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
 
 class Method:
     def __init__(self, name):
@@ -270,6 +291,9 @@ class Method:
         if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true':
             self.deprecated = True
 
+        for a in self.annotations:
+            a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
+
 class Signal:
     def __init__(self, name):
         self.name = name
@@ -305,6 +329,9 @@ class Signal:
         if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true':
             self.deprecated = True
 
+        for a in self.annotations:
+            a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
+
 class Property:
     def __init__(self, name, signature, access):
         self.name = name
@@ -357,6 +384,9 @@ class Property:
         if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true':
             self.deprecated = True
 
+        for a in self.annotations:
+            a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
+
         # FIXME: for now we only support 'false' and 'const' on the signal itself, see #674913 and
         # http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format
         # for details
@@ -436,3 +466,6 @@ class Interface:
 
         for p in self.properties:
             p.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
+
+        for a in self.annotations:
+            a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)


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