1#! /usr/bin/env python
2import sys, os, re
3
4index = 'cwg_index.html'
5output = 'cxx_dr_status.html'
6dr_test_dir = '../test/CXX/drs'
7
8if len(sys.argv) == 1:
9  pass
10elif len(sys.argv) == 2:
11  index = sys.argv[1]
12else:
13  print >>sys.stderr, 'Usage: make_drs [<path to cwg_index.html>]'
14  sys.exit(1)
15
16class DR:
17  def __init__(self, section, issue, url, status, title):
18    self.section, self.issue, self.url, self.status, self.title = \
19        section, issue, url, status, title
20  def __repr__(self):
21    return '%s (%s): %s' % (self.issue, self.status, self.title)
22
23def parse(dr):
24  section, issue_link, status, title = [
25      col.split('>', 1)[1].split('</TD>')[0]
26      for col in dr.split('</TR>', 1)[0].split('<TD')[1:]
27  ]
28  _, url, issue = issue_link.split('"', 2)
29  url = url.strip()
30  issue = int(issue.split('>', 1)[1].split('<', 1)[0])
31  title = title.replace('<issue_title>', '').replace('</issue_title>', '').replace('\r\n', '\n').strip()
32  return DR(section, issue, url, status, title)
33
34status_re = re.compile(r'\bdr([0-9]+): (.*)')
35status_map = {}
36for test_cpp in os.listdir(dr_test_dir):
37  if not test_cpp.endswith('.cpp'):
38    continue
39  test_cpp = os.path.join(dr_test_dir, test_cpp)
40  found_any = False;
41  for match in re.finditer(status_re, file(test_cpp, 'r').read()):
42    status_map[int(match.group(1))] = match.group(2)
43    found_any = True
44  if not found_any:
45    print >> sys.stderr, "warning:%s: no '// dr123: foo' comments in this file" % test_cpp
46
47drs = sorted((parse(dr) for dr in file(index, 'r').read().split('<TR>')[2:]),
48             key = lambda dr: dr.issue)
49out_file = file(output, 'w')
50
51print >> out_file, '''\
52<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
53          "http://www.w3.org/TR/html4/strict.dtd">
54<!-- This file is auto-generated by make_cxx_dr_status. Do not modify. -->
55<html>
56<head>
57  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
58  <title>Clang - C++ Defect Report Status</title>
59  <link type="text/css" rel="stylesheet" href="menu.css">
60  <link type="text/css" rel="stylesheet" href="content.css">
61  <style type="text/css">
62    .none { background-color: #FFCCCC }
63    .partial { background-color: #FFE0B0 }
64    .unreleased { background-color: #FFFF99 }
65    .full { background-color: #CCFF99 }
66    .na { background-color: #DDDDDD }
67    .open * { color: #AAAAAA }
68    //.open { filter: opacity(0.2) }
69    tr:target { background-color: #FFFFBB }
70    th { background-color: #FFDDAA }
71  </style>
72</head>
73<body>
74
75<!--#include virtual="menu.html.incl"-->
76
77<div id="content">
78
79<!--*************************************************************************-->
80<h1>C++ Defect Report Support in Clang</h1>
81<!--*************************************************************************-->
82<p>Last updated: $Date$</p>
83
84<h2 id="cxxdr">C++ defect report implementation status</h2>
85
86<p>This page tracks which C++ defect reports are implemented within Clang.</p>
87
88<table width="689" border="1" cellspacing="0">
89  <tr>
90    <th>Number</th>
91    <th>Status</th>
92    <th>Issue title</th>
93    <th>Available in Clang?</th>
94  </tr>'''
95
96latest_release = 11
97
98def availability(issue):
99  status = status_map.get(issue, 'unknown')
100  avail_suffix = ''
101  if status.endswith(' c++11'):
102    status = status[:-6]
103    avail_suffix = ' (C++11 onwards)'
104  elif status.endswith(' c++14'):
105    status = status[:-6]
106    avail_suffix = ' (C++14 onwards)'
107  elif status.endswith(' c++17'):
108    status = status[:-6]
109    avail_suffix = ' (C++17 onwards)'
110  if status == 'unknown':
111    avail = 'Unknown'
112    avail_style = ' class="none"'
113  elif re.match('^[0-9]+\.?[0-9]*', status):
114    avail = 'Clang %s' % status
115    if float(status) > latest_release:
116      avail_style = ' class="unreleased"'
117    else:
118      avail_style = ' class="full"'
119  elif status == 'yes':
120    avail = 'Yes'
121    avail_style = ' class="full"'
122  elif status == 'partial':
123    avail = 'Partial'
124    avail_style = ' class="partial"'
125  elif status == 'no':
126    avail = 'No'
127    avail_style = ' class="none"'
128  elif status == 'na':
129    avail = 'N/A'
130    avail_style = ' class="na"'
131  elif status == 'na lib':
132    avail = 'N/A (Library DR)'
133    avail_style = ' class="na"'
134  elif status == 'na abi':
135    avail = 'N/A (ABI constraint)'
136    avail_style = ' class="na"'
137  elif status.startswith('sup '):
138    dup = status.split(' ', 1)[1]
139    avail = 'Superseded by <a href="#%s">%s</a>' % (dup, dup)
140    try:
141      _, avail_style = availability(int(dup))
142    except:
143      print >>sys.stderr, "issue %s marked as sup %s" % (issue, dup)
144      avail_style = ' class="none"'
145  elif status.startswith('dup '):
146    dup = int(status.split(' ', 1)[1])
147    avail = 'Duplicate of <a href="#%s">%s</a>' % (dup, dup)
148    _, avail_style = availability(dup)
149  else:
150    assert False, 'unknown status %s for issue %s' % (status, dr.issue)
151  return (avail + avail_suffix, avail_style)
152
153count = {}
154for dr in drs:
155  if dr.status in ('concepts',):
156    # This refers to the old ("C++0x") concepts feature, which was not part
157    # of any C++ International Standard or Technical Specification.
158    continue
159  if dr.status in ('open', 'concurrency', 'drafting', 'review', 'extension'):
160    # We may have to deal with these some day, but not yet.
161    row_style = ' class="open"'
162    if dr.status == 'extension':
163      avail = 'Extension'
164    else:
165      avail = 'Not resolved'
166    avail_style = ''
167    assert dr.issue not in status_map, "have status for not-ready dr %s" % dr.issue
168  else:
169    row_style = ''
170    avail, avail_style = availability(dr.issue)
171    if not avail.startswith('Sup') and not avail.startswith('Dup'):
172      count[avail] = count.get(avail, 0) + 1
173
174  print >> out_file, '''\
175  <tr%s id="%s">
176    <td><a href="https://wg21.link/cwg%s">%s</a></td>
177    <td>%s</td>
178    <td>%s</td>
179    <td%s align="center">%s</td>
180  </tr>''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail)
181
182for status, num in sorted(count.items()):
183  print "%s: %s" % (status, num)
184
185print >> out_file, '''\
186</table>
187
188</div>
189</body>
190</html>'''
191