diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 15:15:47 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 15:15:47 -0500 |
| commit | d17c0975d2a7b5d201e6a07cdcc43ad957783230 (patch) | |
| tree | 537dc8c017cb1364e593247ac7ecddbe30bdba64 /tools | |
| parent | 1a6ec4a7bd80f378ad0eb4b62424343703494ce6 (diff) | |
| parent | 251b00d688c4ab70a05a7370122ce52f33a24687 (diff) | |
Merge pull request #3215 from Leo Leahy
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/rbf0_encode.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/rbf0_encode.py b/tools/rbf0_encode.py index eaf9d9c04..2cf46a68e 100644 --- a/tools/rbf0_encode.py +++ b/tools/rbf0_encode.py | |||
| @@ -66,17 +66,23 @@ class _Writer: | |||
| 66 | if index > self.emitted: | 66 | if index > self.emitted: |
| 67 | raise EncodeError("descriptor", f"descriptor {index} is used before descriptor {self.emitted}") | 67 | raise EncodeError("descriptor", f"descriptor {index} is used before descriptor {self.emitted}") |
| 68 | self.out += bytes((index, kind)) | 68 | self.out += bytes((index, kind)) |
| 69 | name = node.get("name", "") | ||
| 69 | if index == self.emitted: | 70 | if index == self.emitted: |
| 70 | name = node.get("name", "") | ||
| 71 | if index in self.bad_names: | 71 | if index in self.bad_names: |
| 72 | raise EncodeError("utf8", f"descriptor {index} name had invalid UTF-8") | 72 | raise EncodeError("utf8", f"descriptor {index} name had invalid UTF-8") |
| 73 | if index < len(self.names) and self.names[index] not in (None, name): | 73 | if index < len(self.names) and self.names[index] not in (None, name): |
| 74 | raise EncodeError("descriptor", f"descriptor {index} is named both {self.names[index]!r} and {name!r}") | 74 | raise EncodeError("descriptor", f"descriptor {index} is named both {self.names[index]!r} and {name!r}") |
| 75 | if index == len(self.names): | ||
| 76 | self.names.append(name) | ||
| 77 | else: | ||
| 78 | self.names[index] = name | ||
| 75 | raw = name.encode("utf-8") | 79 | raw = name.encode("utf-8") |
| 76 | if len(raw) > 0xFFFF: | 80 | if len(raw) > 0xFFFF: |
| 77 | raise EncodeError("length", f"descriptor {index} name is {len(raw)} bytes") | 81 | raise EncodeError("length", f"descriptor {index} name is {len(raw)} bytes") |
| 78 | self.out += struct.pack("<H", len(raw)) + raw | 82 | self.out += struct.pack("<H", len(raw)) + raw |
| 79 | self.emitted += 1 | 83 | self.emitted += 1 |
| 84 | elif index < len(self.names) and self.names[index] not in (None, name): | ||
| 85 | raise EncodeError("descriptor", f"descriptor {index} is named both {self.names[index]!r} and {name!r}") | ||
| 80 | 86 | ||
| 81 | def float_bits(self, value, special): | 87 | def float_bits(self, value, special): |
| 82 | if special is not None: | 88 | if special is not None: |