Skip to content

Commit

Permalink
In PRNT chunks, write links in depth-first order (rojo-rbx#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekkonot authored May 13, 2024
1 parent c5bb118 commit 0fa0341
Show file tree
Hide file tree
Showing 38 changed files with 286 additions and 266 deletions.
4 changes: 4 additions & 0 deletions rbx_binary/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Within `PRNT` chunks, parent-child links are now generated depth-first so that parents always come after their children in the chunk. ([#411])

[#411]: https://github.com/rojo-rbx/rbx-dom/pull/411

## 0.7.4 (2024-01-16)
* Add the ability to specify a `ReflectionDatabase` to use for serializing and deserializing. This takes the form of `Deserializer::reflection_database` and `Serializer::reflection_database`. ([#375])

Expand Down
3 changes: 2 additions & 1 deletion rbx_binary/src/serializer/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,9 +1249,10 @@ impl<'dom, 'db, W: Write> SerializerState<'dom, 'db, W> {
let object_referents = self
.relevant_instances
.iter()
.rev()
.map(|id| self.id_to_referent[id]);

let parent_referents = self.relevant_instances.iter().map(|id| {
let parent_referents = self.relevant_instances.iter().rev().map(|id| {
let instance = self.dom.get_by_ref(*id).unwrap();

// If there's no parent set OR our parent is not one of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ chunks:
- Prnt:
version: 0
links:
- - 0
- -1
- - 1
- -1
- - 0
- -1
- End

Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ chunks:
- Prnt:
version: 0
links:
- - 0
- - 2
- -1
- - 1
- -1
- - 2
- - 0
- -1
- End

Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ chunks:
- Prnt:
version: 0
links:
- - 0
- -1
- - 1
- - 7
- 0
- - 2
- - 6
- 0
- - 3
- - 5
- 0
- - 4
- 0
- - 5
- - 3
- 0
- - 6
- - 2
- 0
- - 7
- - 1
- 0
- - 0
- -1
- End

Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ chunks:
- Prnt:
version: 0
links:
- - 0
- -1
- - 1
- - 3
- -1
- - 2
- -1
- - 3
- - 1
- -1
- - 0
- -1
- End

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ chunks:
- Prnt:
version: 0
links:
- - 0
- -1
- - 1
- -1
- - 0
- -1
- End

Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,21 @@ chunks:
- Prnt:
version: 0
links:
- - 0
- -1
- - 1
- - 7
- -1
- - 2
- - 6
- -1
- - 3
- - 5
- -1
- - 4
- -1
- - 5
- - 3
- -1
- - 6
- - 2
- -1
- - 7
- - 1
- -1
- - 0
- -1
- End

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: rbx_binary/src/tests/util.rs
assertion_line: 46
expression: text_roundtrip
---
num_types: 60
Expand Down Expand Up @@ -4267,125 +4268,125 @@ chunks:
- Prnt:
version: 0
links:
- - 0
- -1
- - 1
- - 59
- 49
- - 58
- 47
- - 57
- 39
- - 56
- 39
- - 55
- 39
- - 54
- 39
- - 53
- 39
- - 52
- 21
- - 51
- 13
- - 50
- 13
- - 49
- 0
- - 48
- 0
- - 47
- 0
- - 46
- 0
- - 45
- -1
- - 2
- - 44
- -1
- - 3
- - 43
- -1
- - 4
- - 42
- -1
- - 5
- - 41
- -1
- - 6
- - 40
- -1
- - 7
- - 39
- -1
- - 8
- - 38
- -1
- - 9
- - 37
- -1
- - 10
- - 36
- -1
- - 11
- - 35
- -1
- - 12
- - 34
- -1
- - 13
- - 33
- -1
- - 14
- - 32
- -1
- - 15
- - 31
- -1
- - 16
- - 30
- -1
- - 17
- - 29
- -1
- - 18
- - 28
- -1
- - 19
- - 27
- -1
- - 20
- - 26
- -1
- - 21
- - 25
- -1
- - 22
- - 24
- -1
- - 23
- -1
- - 24
- - 22
- -1
- - 25
- - 21
- -1
- - 26
- - 20
- -1
- - 27
- - 19
- -1
- - 28
- - 18
- -1
- - 29
- - 17
- -1
- - 30
- - 16
- -1
- - 31
- - 15
- -1
- - 32
- - 14
- -1
- - 33
- - 13
- -1
- - 34
- - 12
- -1
- - 35
- - 11
- -1
- - 36
- - 10
- -1
- - 37
- - 9
- -1
- - 38
- - 8
- -1
- - 39
- - 7
- -1
- - 40
- - 6
- -1
- - 41
- - 5
- -1
- - 42
- - 4
- -1
- - 43
- - 3
- -1
- - 44
- - 2
- -1
- - 45
- - 1
- -1
- - 0
- -1
- - 46
- 0
- - 47
- 0
- - 48
- 0
- - 49
- 0
- - 50
- 13
- - 51
- 13
- - 52
- 21
- - 53
- 39
- - 54
- 39
- - 55
- 39
- - 56
- 39
- - 57
- 39
- - 58
- 47
- - 59
- 49
- End

Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ chunks:
- Prnt:
version: 0
links:
- - 0
- -1
- - 1
- -1
- - 0
- -1
- End

Loading

0 comments on commit 0fa0341

Please sign in to comment.