logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

1.32-deprecation-parse-fixes.patch (7181B)


  1. From 2667d8cd95a2a29c35c1bb8f4629c22fd0aa98e9 Mon Sep 17 00:00:00 2001
  2. From: Xavier Claessens <xavier.claessens@collabora.com>
  3. Date: Thu, 2 Jan 2020 21:56:10 -0500
  4. Subject: [PATCH 1/3] Skip G_GNUC_(BEGIN|END)_IGNORE_DEPRECATIONS lines
  5. For some reason, glib has to put empty line before and after each of
  6. these lines otherwise the symbol following it is undeclared.
  7. ---
  8. gtkdoc/scan.py | 5 +++++
  9. 1 file changed, 5 insertions(+)
  10. diff --git a/gtkdoc/scan.py b/gtkdoc/scan.py
  11. index d04d4d4..7de08ad 100644
  12. --- a/gtkdoc/scan.py
  13. +++ b/gtkdoc/scan.py
  14. @@ -561,6 +561,11 @@ def ScanHeaderContent(input_lines, decl_list, get_types, options):
  15. logging.info('Found start of comment: %s', line.strip())
  16. continue
  17. + # Skip begin/end deprecation macros.
  18. + m = re.search(r'^\s*G_GNUC_(BEGIN|END)_IGNORE_DEPRECATIONS', line)
  19. + if m:
  20. + continue
  21. +
  22. logging.info('no decl: %s', line.strip())
  23. cm = [m.match(line) for m in CLINE_MATCHER]
  24. --
  25. 2.20.1
  26. From 9e58548688c9768cf41c59ccef531d438ffb2504 Mon Sep 17 00:00:00 2001
  27. From: Xavier Claessens <xavier.claessens@collabora.com>
  28. Date: Fri, 3 Jan 2020 06:47:47 -0500
  29. Subject: [PATCH 2/3] typedef can be followed by decorator
  30. ---
  31. gtkdoc/scan.py | 30 +++++++++++++++++-------------
  32. 1 file changed, 17 insertions(+), 13 deletions(-)
  33. diff --git a/gtkdoc/scan.py b/gtkdoc/scan.py
  34. index 7de08ad..5a5da92 100644
  35. --- a/gtkdoc/scan.py
  36. +++ b/gtkdoc/scan.py
  37. @@ -96,19 +96,8 @@ CLINE_MATCHER = [
  38. (struct|union)\s*
  39. \w*\s*{""", re.VERBOSE),
  40. # 12-14: OTHER TYPEDEFS
  41. - re.compile(
  42. - r"""^\s*typedef\s+
  43. - (?:struct|union)\s+\w+[\s\*]+
  44. - (\w+) # 1: name
  45. - \s*;""", re.VERBOSE),
  46. - re.compile(
  47. - r"""^\s*
  48. - (?:G_GNUC_EXTENSION\s+)?
  49. - typedef\s+
  50. - (.+[\s\*]) # 1: e.g. 'unsigned int'
  51. - (\w+) # 2: name
  52. - (?:\s*\[[^\]]+\])*
  53. - \s*;""", re.VERBOSE),
  54. + None, # in InitScanner()
  55. + None, # in InitScanner()
  56. re.compile(r'^\s*typedef\s+'),
  57. # 15: VARIABLES (extern'ed variables)
  58. None, # in InitScanner()
  59. @@ -267,6 +256,21 @@ def InitScanner(options):
  60. %s # 3: optional decorator
  61. \s*;""" % optional_decorators_regex, re.VERBOSE)
  62. # OTHER TYPEDEFS
  63. + CLINE_MATCHER[12] = re.compile(
  64. + r"""^\s*typedef\s+
  65. + (?:struct|union)\s+\w+[\s\*]+
  66. + (\w+) # 1: name
  67. + %s # 2: optional decorator
  68. + \s*;""" % optional_decorators_regex, re.VERBOSE)
  69. + CLINE_MATCHER[13] = re.compile(
  70. + r"""^\s*
  71. + (?:G_GNUC_EXTENSION\s+)?
  72. + typedef\s+
  73. + (.+?[\s\*]) # 1: e.g. 'unsigned int'
  74. + (\w+) # 2: name
  75. + (?:\s*\[[^\]]+\])*
  76. + %s # 3: optional decorator
  77. + \s*;""" % optional_decorators_regex, re.VERBOSE)
  78. CLINE_MATCHER[15] = re.compile(
  79. r"""^\s*
  80. (?:extern|[A-Za-z_]+VAR%s)\s+
  81. --
  82. 2.20.1
  83. From 5bfe23f0257e1b4c6c9a4e3a2dbb180455f753f2 Mon Sep 17 00:00:00 2001
  84. From: Jason Crain <jason@inspiresomeone.us>
  85. Date: Mon, 6 Jan 2020 19:05:42 -0700
  86. Subject: [PATCH 3/3] scan: support deprecated struct members
  87. gcc allows deprecating members of structs. For example:
  88. struct data {
  89. int x G_GNUC_DEPRECATED_FOR(replacement);
  90. };
  91. However, this currently causes the entire struct to be marked as
  92. deprecated and confuses mkdb because it doesn't understand the
  93. G_GNUC_DEPRECATED_FOR symbol.
  94. Fix this by having the whole struct only be marked as deprecated if the
  95. '_DEPRECATED' is after the closing bracket of the struct, similar to how
  96. it already does for enums, and having scan automatically remove all
  97. G_GNUC_* decorators from struct members, similar to how it already does
  98. for functions.
  99. ---
  100. gtkdoc/scan.py | 12 ++++++++++--
  101. tests/scan.py | 17 +++++++++++++++++
  102. 2 files changed, 27 insertions(+), 2 deletions(-)
  103. diff --git a/gtkdoc/scan.py b/gtkdoc/scan.py
  104. index 5a5da92..6c6534a 100644
  105. --- a/gtkdoc/scan.py
  106. +++ b/gtkdoc/scan.py
  107. @@ -538,7 +538,7 @@ def ScanHeaderContent(input_lines, decl_list, get_types, options):
  108. # section (#endif /* XXX_DEPRECATED */
  109. if deprecated_conditional_nest == 0 and '_DEPRECATED' in line:
  110. m = re.search(r'^\s*#\s*(if*|define|endif)', line)
  111. - if not (m or in_declaration == 'enum'):
  112. + if not (m or in_declaration == 'enum' or in_declaration == 'struct'):
  113. logging.info('Found deprecation annotation (decl: "%s"): "%s"',
  114. in_declaration, line.strip())
  115. deprecated_conditional_nest += 0.1
  116. @@ -953,9 +953,17 @@ def ScanHeaderContent(input_lines, decl_list, get_types, options):
  117. title = '<TITLE>%s</TITLE>' % objectname
  118. logging.info('Store struct: "%s"', symbol)
  119. + # Structs could contain deprecated members and that doesn't
  120. + # mean the whole struct is deprecated, so they are ignored when
  121. + # setting deprecated_conditional_nest above. Here we can check
  122. + # if the _DEPRECATED is between '}' and ';' which would mean
  123. + # the struct as a whole is deprecated.
  124. + if re.search(r'\n\s*\}.*_DEPRECATED.*;\s*$', decl):
  125. + deprecated = '<DEPRECATED/>\n'
  126. if AddSymbolToList(slist, symbol):
  127. structsym = in_declaration.upper()
  128. - stripped_decl = re.sub('(%s)' % optional_decorators_regex, '', decl)
  129. + regex = r'(?:\s+(?:G_GNUC_\w+(?:\(\w*\))?%s))' % ignore_decorators
  130. + stripped_decl = re.sub(regex, '', decl)
  131. decl_list.append('<%s>\n<NAME>%s</NAME>\n%s%s</%s>\n' %
  132. (structsym, symbol, deprecated, stripped_decl, structsym))
  133. if symbol in forward_decls:
  134. diff --git a/tests/scan.py b/tests/scan.py
  135. index ad63541..6d608b6 100755
  136. --- a/tests/scan.py
  137. +++ b/tests/scan.py
  138. @@ -552,6 +552,23 @@ class ScanHeaderContentStructs(ScanHeaderContentTestCase):
  139. slist, doc_comments = self.scanHeaderContent([header])
  140. self.assertDecl('data', expected, slist)
  141. + def test_HandleDeprecatedMemberDecorator(self):
  142. + """Struct with deprecated members."""
  143. + header = textwrap.dedent("""\
  144. + struct data {
  145. + int x1 G_GNUC_DEPRECATED;
  146. + int x2 G_GNUC_DEPRECATED_FOR(replacement);
  147. + };""")
  148. + expected = textwrap.dedent("""\
  149. + struct data {
  150. + int x1;
  151. + int x2;
  152. + };""")
  153. + scan.InitScanner(self.options)
  154. + slist, doc_comments = self.scanHeaderContent(
  155. + header.splitlines(keepends=True))
  156. + self.assertDecl('data', expected, slist)
  157. +
  158. class ScanHeaderContentUnions(ScanHeaderContentTestCase):
  159. """Test parsing of union declarations."""
  160. --
  161. 2.20.1