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
This commit is contained in:
Philip Withnall 2018-04-17 14:07:50 +01:00
parent 7830b65c5f
commit 99b64d4014

View File

@ -27,6 +27,25 @@ class Annotation:
self.key = key self.key = key
self.value = value self.value = value
self.annotations = [] 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: class Arg:
def __init__(self, name, signature): def __init__(self, name, signature):
@ -229,6 +248,8 @@ class Arg:
self.gvalue_get = 'g_value_get_boxed' self.gvalue_get = 'g_value_get_boxed'
self.array_annotation = '(array zero-terminated=1)' 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: class Method:
def __init__(self, name): def __init__(self, name):
@ -270,6 +291,9 @@ class Method:
if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true': if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true':
self.deprecated = True self.deprecated = True
for a in self.annotations:
a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
class Signal: class Signal:
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
@ -305,6 +329,9 @@ class Signal:
if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true': if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true':
self.deprecated = True self.deprecated = True
for a in self.annotations:
a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
class Property: class Property:
def __init__(self, name, signature, access): def __init__(self, name, signature, access):
self.name = name self.name = name
@ -356,6 +383,9 @@ class Property:
if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true': if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true':
self.deprecated = True self.deprecated = True
for a in self.annotations:
a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
class Interface: class Interface:
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
@ -429,3 +459,6 @@ class Interface:
for p in self.properties: for p in self.properties:
p.post_process(interface_prefix, cns, cns_upper, cns_lower, self) 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)