-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New patch decompiler #103
base: master
Are you sure you want to change the base?
New patch decompiler #103
Conversation
Reviewer's Guide by SourceryThis PR implements a complete rewrite of the patch decompiler tool to improve its functionality and reliability. The new implementation focuses on better module chain parsing, more robust pattern handling, and cleaner data organization through new class structures. Sequence diagram for decompiling a projectsequenceDiagram
participant User
participant Main
participant Project
participant ModuleChain
participant PatternGroups
participant Patch
participant FileSystem
User->>Main: Run decompile_project
Main->>Project: Read SunVox file
Project-->>Main: Return project data
Main->>ModuleChain: Parse modules
ModuleChain-->>Main: Return module chains
Main->>PatternGroups: Parse timeline
PatternGroups-->>Main: Return pattern groups
Main->>Patch: Create patch for each chain
Patch-->>Main: Return patch
Main->>FileSystem: Dump SunVox and modules
FileSystem-->>Main: Files created
Main-->>User: Decompilation complete
Class diagram for the new patch decompilerclassDiagram
class ModuleChain {
+parse_modules(project)
+clone_modules(project)
+names()
+indexes()
+is_output(item)
}
class Track {
+has_content()
}
class Tracks {
+from_pattern_data(pattern_data)
+filter_by_chain(chain, modules)
+lengths()
+to_pattern_data()
}
class PatternGroup {
+mod_indexes()
+master_tracks(chain, modules)
}
class PatternGroups {
+parse_timeline(project)
+filter_by_chain(chain, filter_fn)
}
ModuleChain --> Track
ModuleChain --> Tracks
Tracks --> Track
PatternGroups --> PatternGroup
PatternGroup --> Tracks
Tracks --> PatternGroup
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jhw - I've reviewed your changes - here's some feedback:
Overall Comments:
- Please provide a more detailed commit message explaining why the rewrite was necessary and what architectural changes were made. The current message "no longer seemed to work (not sure why)" doesn't give enough context for future maintenance.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
||
class ModuleChain(list): | ||
|
||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider simplifying the parse_modules method by combining module lookup with traversal logic.
The parse_modules
method can be simplified while maintaining its functionality. Here's a cleaner approach that reduces nesting and combines the module lookup with traversal:
@staticmethod
def parse_modules(project):
modules = project.modules
def dfs(index):
if not (0 <= index < len(modules)) or not modules[index]:
return []
mod = modules[index]
current = (mod.name, mod.index)
modules[index] = None # Mark as visited
# Base case - no input links
if not mod.in_links:
return [ModuleChain([current])]
# Recursive case - build chains from inputs
chains = []
for prev_index in mod.in_links:
for chain in dfs(prev_index):
chains.append(ModuleChain(chain + [current]))
return sorted(chains, key=lambda x: x[0][1])
return dfs(0)
Key improvements:
- Eliminates separate module dictionary creation
- Uses in-place visited marking instead of a separate set
- Reduces nesting levels in the traversal logic
- Maintains the same module relationship tracking
@jhw I will do what I can to take a look at this today. |
@jhw I finally got a chance to take a quick look at this. One thing that comes to mind superficially is that the master branch is quite outdated and there was a lot of work done on the sunvox-2.0-file-format branch, which along with a TON of other stuff includes some fixes to the original version of your script. I haven't tested it, but I did prepare a branch, sunvox-2.0-file-format--jhw-01-decompiler-v2 that rolls back the changes made to the script and then applies your branch. But, bigger-picture, I'd like to have a broader discussion about the future of the project and how you might be able to port your script over to the native SunVox lib. I'll open that up separately and ping you there! |
The existing patch decompiler no longer seemed to work (not sure why) so I improved and extended it somewhat
Summary by Sourcery
Implement a new patch decompiler for SunVox projects, improving module chain parsing and pattern handling.
New Features:
Enhancements: