Skip to content

Commit 0944c8b

Browse files
committed
Remove dangerous usage of non-public parts of the systemrdl-compiler API
1 parent 080fc13 commit 0944c8b

9 files changed

Lines changed: 61 additions & 66 deletions

File tree

docs/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<link rel="stylesheet" href="css/theme.css?v=2.11.0">
1515
<link rel="icon" type="image/png" href="favicon.png">
1616
<script>
17-
var BUILD_TS = 1745433649;
17+
var BUILD_TS = 1763240971;
1818
</script>
1919
<script async src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
2020
<script type="text/x-mathjax-config">
@@ -26,8 +26,8 @@
2626
</script>
2727
<script src="js/progressbar.min.js?v=2.11.0" type="text/javascript"></script>
2828
<script src="js/sha1.js?v=2.11.0" type="text/javascript"></script>
29-
<script src="data/data_index.js?ts=1745433649" type="text/javascript"></script>
30-
<script src="search/bkt_index.js?ts=1745433649" type="text/javascript"></script>
29+
<script src="data/data_index.js?ts=1763240971" type="text/javascript"></script>
30+
<script src="search/bkt_index.js?ts=1763240971" type="text/javascript"></script>
3131
<script src="js/ral.js?v=2.11.0" type="text/javascript"></script>
3232
<script src="js/main.js?v=2.11.0" type="text/javascript"></script>
3333
<script src="js/nav.js?v=2.11.0" type="text/javascript"></script>

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "peakrdl-html"
77
dynamic = ["version"]
88
requires-python = ">=3.7"
99
dependencies = [
10-
"systemrdl-compiler ~= 1.13",
10+
"systemrdl-compiler ~= 1.31",
1111
"Jinja2 >= 2.9",
1212
"markdown",
1313
"git-me-the-url >= 2.0.3",

src/peakrdl_html/exporter.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def export(self, nodes: 'Union[Node, List[Node]]', output_dir: str, **kwargs: 'D
176176
if node.get_property('bridge'):
177177
node.env.msg.warning(
178178
"HTML generator does not have proper support for bridge addmaps yet. The 'bridge' property will be ignored.",
179-
node.inst.property_src_ref.get('bridge', node.inst.inst_src_ref)
179+
node.property_src_ref.get('bridge', node.inst_src_ref)
180180
)
181181
self.visit_addressable_node(node)
182182

@@ -190,7 +190,7 @@ def export(self, nodes: 'Union[Node, List[Node]]', output_dir: str, **kwargs: 'D
190190
self.indexer.write_index_js(os.path.join(output_dir, "search"))
191191

192192

193-
def visit_addressable_node(self, node: Node, parent_id: 'Optional[int]'=None) -> int:
193+
def visit_addressable_node(self, node: AddressableNode, parent_id: 'Optional[int]'=None) -> int:
194194
self.current_id += 1
195195
this_id = self.current_id
196196
child_ids = [] # type: List[int]
@@ -200,14 +200,15 @@ def visit_addressable_node(self, node: Node, parent_id: 'Optional[int]'=None) ->
200200
ral_entry = {
201201
'parent' : parent_id,
202202
'children' : child_ids,
203-
'name' : node.inst.inst_name,
204-
'offset' : BigInt(node.inst.addr_offset),
203+
'name' : node.inst_name,
204+
'offset' : BigInt(node.raw_address_offset),
205205
'size' : BigInt(node.size),
206206
}
207-
if node.inst.is_array:
208-
ral_entry['dims'] = node.inst.array_dimensions
209-
ral_entry['stride'] = BigInt(node.inst.array_stride)
210-
ral_entry['idxs'] = [0] * len(node.inst.array_dimensions)
207+
if node.array_dimensions:
208+
assert node.array_stride is not None
209+
ral_entry['dims'] = node.array_dimensions
210+
ral_entry['stride'] = BigInt(node.array_stride)
211+
ral_entry['idxs'] = [0] * len(node.array_dimensions)
211212

212213
if isinstance(node, RegNode):
213214
ral_fields = []
@@ -221,9 +222,9 @@ def visit_addressable_node(self, node: Node, parent_id: 'Optional[int]'=None) ->
221222
field_reset = 0
222223

223224
ral_field = {
224-
'name' : field.inst.inst_name,
225-
'lsb' : field.inst.lsb,
226-
'msb' : field.inst.msb,
225+
'name' : field.inst_name,
226+
'lsb' : field.lsb,
227+
'msb' : field.msb,
227228
'reset': BigInt(field_reset),
228229
'disp' : 'H'
229230
}
@@ -399,7 +400,7 @@ def img_transform_callback(m: 're.Match') -> str:
399400
else:
400401
# Looks like a relative path
401402
# See if it points to something relative to the source file
402-
path = self.try_resolve_rel_path(node.inst.def_src_ref, img_src)
403+
path = self.try_resolve_rel_path(node.def_src_ref, img_src)
403404
if path is not None:
404405
img_src = path
405406

@@ -468,7 +469,7 @@ def get_view_source_info(self, node: Node) -> 'Tuple[Optional[str], Optional[str
468469
if not self.generate_source_links:
469470
return None, None
470471

471-
src_ref = node.inst.def_src_ref or node.inst.inst_src_ref
472+
src_ref = node.def_src_ref or node.inst_src_ref
472473
if isinstance(src_ref, DetailedFileSourceRef):
473474
path = src_ref.path
474475
line = src_ref.line

src/peakrdl_html/search_indexer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def _write_bucket_file() -> None:
207207
#self._debug_print_stats(buckets)
208208

209209

210-
def _debug_print_stats(self, buckets):
210+
def _debug_print_stats(self, buckets: dict) -> None:
211211
word_counts = []
212212
for word, locations in self.index.items():
213213
word_counts.append((len(locations), word))

src/peakrdl_html/templates/base.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ <h1 id="_Content.name">{{(node.get_html_name() or node.get_property("name"))|saf
1010
<div id="_AbsAddrDetails"></div>
1111
<dt>Base Offset:</dt><dd class="address">{{"0x%x" % node.raw_address_offset}}</dd>
1212
<dt>Size:</dt><dd class="address">{{"0x%x" % node.size}}</dd>
13-
{%- if node.inst.is_array %}
14-
<dt>Array Dimensions:</dt><dd>{{node.inst.array_dimensions}}</dd>
15-
<dt>Array Stride:</dt><dd>+{{"0x%x" % node.inst.array_stride}}</dd>
13+
{%- if node.is_array %}
14+
<dt>Array Dimensions:</dt><dd>{{node.array_dimensions}}</dd>
15+
<dt>Array Stride:</dt><dd>+{{"0x%x" % node.array_stride}}</dd>
1616
<dt>Total Size:</dt><dd class="address">{{"0x%x" % node.total_size}}</dd>
1717
{%- endif %}
1818
{% if view_source_url is not none %}

src/peakrdl_html/templates/field_description.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{%- import "macros.html" as macros with context %}
2-
<h3 id="{{field.inst.inst_name}}.desc">
2+
<h3 id="{{field.inst_name}}.desc">
33
{%- if field.get_property("name", default="") == "" -%}
4-
{{- field.inst.inst_name -}}
4+
{{- field.inst_name -}}
55
{%- else -%}
6-
{{- field.inst.inst_name}} - {{field.get_html_name()|safe -}}
6+
{{- field.inst_name}} - {{field.get_html_name()|safe -}}
77
{%- endif %}
8-
<a class="headerlink" href="#{{field.inst.inst_name}}.desc" title="Permalink to this headline"></a>
8+
<a class="headerlink" href="#{{field.inst_name}}.desc" title="Permalink to this headline"></a>
99
</h3>
10-
<div id="_Content.{{field.inst.inst_name}}.desc">
10+
<div id="_Content.{{field.inst_name}}.desc">
1111
{%- if has_description(field) %}
1212
{{get_node_desc(field,3)|safe}}
1313
{%- endif %}

src/peakrdl_html/templates/group-like.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@
1919
</tr>
2020
{%- set addr_digits = get_child_addr_digits(node) -%}
2121
{%- for child_id,child in children.items() %}
22-
{%- if loop.first and child.inst.addr_offset != 0 %}
23-
{{reserved_addr(child.inst.addr_offset-1, addr_digits)}}
24-
{%- elif (not loop.first) and (loop.previtem[1].inst.addr_offset + loop.previtem[1].total_size) < child.inst.addr_offset %}
22+
{%- if loop.first and child.raw_address_offset != 0 %}
23+
{{reserved_addr(child.raw_address_offset-1, addr_digits)}}
24+
{%- elif (not loop.first) and (loop.previtem[1].inst.addr_offset + loop.previtem[1].total_size) < child.raw_address_offset %}
2525
{{reserved_addr(loop.previtem[1].inst.addr_offset + loop.previtem[1].total_size, addr_digits)}}
2626
{%- endif %}
27-
<tr id="{{child.inst.inst_name}}">
28-
<td class="address">{{"0x{n:0{width}X}".format(n=child.inst.addr_offset, width=addr_digits)}}</td>
27+
<tr id="{{child.inst_name}}">
28+
<td class="address">{{"0x{n:0{width}X}".format(n=child.raw_address_offset, width=addr_digits)}}</td>
2929
<td><a href="?p={{child.get_path(empty_array_suffix='')}}" data-id="{{child_id}}" onclick="onClickNodeLink(event); return(false)">
30-
{%- if child.inst.is_array -%}
31-
{{child.inst.inst_name}}{% for dim in child.inst.array_dimensions %}[{{dim}}]{% endfor %}
30+
{%- if child.is_array -%}
31+
{{child.inst_name}}{% for dim in child.array_dimensions %}[{{dim}}]{% endfor %}
3232
{%- else -%}
33-
{{child.inst.inst_name}}
33+
{{child.inst_name}}
3434
{%- endif -%}
3535
</a></td>
3636
<td>{{(child.get_html_name() or "-")|safe}}</td>
3737
<td>
38-
<a class="headerlink" href="#{{child.inst.inst_name}}" title="Permalink to this row"></a>
38+
<a class="headerlink" href="#{{child.inst_name}}" title="Permalink to this row"></a>
3939
</td>
4040
</tr>
4141
{%- endfor %}
4242
</table>
43-
{%- endblock content %}
43+
{%- endblock content %}

src/peakrdl_html/templates/reg_base.html

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@
3030
<th></th>
3131
</tr>
3232
{%- for field in reversed(list(node.fields(skip_not_present=skip_not_present))) %}
33-
{%- if loop.first and field.inst.high < (node.get_property('regwidth') - 1) %}
34-
{{reserved_field(node.get_property('regwidth') - 1, field.inst.high + 1, reg_fields_are_low_to_high(node))}}
35-
{%- elif (not loop.first) and field.inst.high < loop.previtem.inst.low - 1 %}
36-
{{reserved_field(loop.previtem.inst.low - 1, field.inst.high + 1, reg_fields_are_low_to_high(node))}}
33+
{%- if loop.first and field.high < (node.get_property('regwidth') - 1) %}
34+
{{reserved_field(node.get_property('regwidth') - 1, field.high + 1, reg_fields_are_low_to_high(node))}}
35+
{%- elif (not loop.first) and field.high < loop.previtem.low - 1 %}
36+
{{reserved_field(loop.previtem.low - 1, field.high + 1, reg_fields_are_low_to_high(node))}}
3737
{%- endif %}
38-
<tr id="{{field.inst.inst_name}}">
39-
{%- if field.inst.msb == field.inst.lsb %}
40-
<td>[{{field.inst.lsb}}]</td>
38+
<tr id="{{field.inst_name}}">
39+
{%- if field.msb == field.lsb %}
40+
<td>[{{field.lsb}}]</td>
4141
{%- else %}
42-
<td>[{{field.inst.msb}}:{{field.inst.lsb}}]</td>
42+
<td>[{{field.msb}}:{{field.lsb}}]</td>
4343
{%- endif %}
4444
<td>
4545
{%- if (has_description(field) or has_enum_encoding(field)) -%}
46-
<a href="#{{field.inst.inst_name}}.desc">{{field.inst.inst_name}}</a>
46+
<a href="#{{field.inst_name}}.desc">{{field.inst_name}}</a>
4747
{%- else -%}
48-
{{- field.inst.inst_name -}}
48+
{{- field.inst_name -}}
4949
{%- endif -%}
5050
</td>
5151
<td>
@@ -69,12 +69,12 @@
6969
{%- endif %}
7070
</td>
7171
<td>
72-
<input id="_FieldValueTester{{field.inst.inst_name}}" class="field-value-tester"
72+
<input id="_FieldValueTester{{field.inst_name}}" class="field-value-tester"
7373
type="text" autocomplete="off"
74-
data-name="{{field.inst.inst_name}}" oninput="onDecodedFieldInput(this)"/>
74+
data-name="{{field.inst_name}}" oninput="onDecodedFieldInput(this)"/>
7575
{%- if field.get_property("encode") != None %}
76-
<select id="_FieldValueEnumTester{{field.inst.inst_name}}" class="field-value-enum-tester"
77-
data-name="{{field.inst.inst_name}}" onchange="onDecodedFieldEnumChange(this)">
76+
<select id="_FieldValueEnumTester{{field.inst_name}}" class="field-value-enum-tester"
77+
data-name="{{field.inst_name}}" onchange="onDecodedFieldEnumChange(this)">
7878
{% for member in field.get_property("encode") %}
7979
<option value="{{'0x%x' % member.value}}">{{member.name}}</option>
8080
{% endfor %}
@@ -83,14 +83,14 @@
8383
</td>
8484
<td>{{(field.get_html_name() or "-")|safe}}</td>
8585
<td>
86-
<button type="button" id="_RadixButton{{field.inst.inst_name}}" class="radix-button"
86+
<button type="button" id="_RadixButton{{field.inst_name}}" class="radix-button"
8787
title="Switch radix" aria-label="Switch radix"
88-
data-name="{{field.inst.inst_name}}" onclick="onRadixSwitch(this)">H</button>
89-
<a class="headerlink" href="#{{field.inst.inst_name}}" title="Permalink to this row"></a>
88+
data-name="{{field.inst_name}}" onclick="onRadixSwitch(this)">H</button>
89+
<a class="headerlink" href="#{{field.inst_name}}" title="Permalink to this row"></a>
9090
</td>
9191
</tr>
92-
{%- if loop.last and field.inst.low != 0 %}
93-
{{reserved_field(field.inst.low - 1, 0, reg_fields_are_low_to_high(node))}}
92+
{%- if loop.last and field.low != 0 %}
93+
{{reserved_field(field.low - 1, 0, reg_fields_are_low_to_high(node))}}
9494
{%- endif %}
9595
{%- endfor %}
9696
</table>

test/pylint.rc

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ load-plugins=
5050
# Pickle collected data for later comparisons.
5151
persistent=yes
5252

53-
# When enabled, pylint would attempt to guess common misconfiguration and emit
54-
# user-friendly hints instead of false-positive error messages.
55-
suggestion-mode=yes
56-
5753
# Allow loading of arbitrary C extensions. Extensions are imported into the
5854
# active Python interpreter and may run arbitrary code.
5955
unsafe-load-any-extension=no
@@ -98,10 +94,8 @@ disable=
9894
abstract-method,
9995
protected-access,
10096
duplicate-code,
101-
cyclic-import,
97+
unused-argument,
10298
unidiomatic-typecheck,
103-
104-
# Can't do until py35 support is dropped
10599
consider-using-f-string
106100

107101
# Enable the message, report, category or checker with the given id(s). You can
@@ -145,7 +139,7 @@ max-nested-blocks=5
145139
# inconsistent-return-statements if a never returning function is called then
146140
# it will be considered as an explicit return statement and no message will be
147141
# printed.
148-
never-returning-functions=sys.exit
142+
never-returning-functions=sys.exit,argparse.parse_error
149143

150144

151145
[STRING]
@@ -495,7 +489,7 @@ valid-metaclass-classmethod-first-arg=cls
495489
ignored-parents=
496490

497491
# Maximum number of arguments for function / method.
498-
max-args=8
492+
max-args=16
499493

500494
# Maximum number of attributes for a class (see R0902).
501495
max-attributes=7
@@ -570,5 +564,5 @@ preferred-modules=
570564

571565
# Exceptions that will emit a warning when being caught. Defaults to
572566
# "BaseException, Exception".
573-
overgeneral-exceptions=BaseException,
574-
Exception
567+
overgeneral-exceptions=builtin.BaseException,
568+
builtin.Exception

0 commit comments

Comments
 (0)