let's say, not entirely hypothetically, that we have a ResEdit TMPL. We want to convert it to an MPW Rez types file, so we can DeRez resources instead of mess with the GUI editor. Anyone got a tool handy for this?

#classicmac #lazyweb #marchintosh

@atax1a @joe Isn't this what DeRez(1) does? Or did I misinterpret your starting point?
@jrose @joe DeRez does that, but only for system types. TMPLs are a ResEdit mechanism to describe other types, but you can't DeRez a TMPL into a .r file. DeRes wants a .r file, not a TMPL.
@atax1a @joe I see, you need a TMPL.r to feed in as a meta-TMPL or something. Thanks for explaining, hope someone can help.
@jrose @joe right, ResEdit is to TMPL as DeRez is to .r but there isn't a handy-dandy converter. rip/dip

@atax1a that is a thing that I wanted to build for fun at one point, but I stopped after finishing most of the required groundwork (as you do). I wrote some Kaitai Struct specs for parsing resource forks and the TMPL resource format, but never got around to writing an actual TMPL converter. idk if this is in any way useful for what you're trying to do

https://formats.kaitai.io/resource_fork/
https://github.com/dgelessus/resource_fork.ksy/blob/master/src/resources/resedit_template_resource.ksy

Macintosh resource fork data format spec for Kaitai Struct

Kaitai Struct is a formal language for binary format specification that can be compiled into parser code

@atax1a Do you have some kind of workflow that you want to integrate this into, or do you just have a couple of TMPLs that you want to convert once?

Depending on how many TMPLs you have and how complex they are, it might be easier to do the conversion manually... I also vaguely remember that some of ResEdit's TMPL data types don't map straightforwardly onto anything in the Rez language, so an automated conversion might not even always work well

@dgelessus we have a ResCompare patch application whose patches we wanted to dump out in a more legible format. we may just end up running RezCompare and recreating the patch, though

@atax1a ah. I never looked at how ResCompare stores its patches - I assume it's a custom format that stores which parts of which resource have changed, so the patch application doesn't contain full patched resources?

In that case it might indeed be easier to just run the patch, DeRez the before and after version, and diff those

@dgelessus we had been hoping to get a textual equivalent of this, but that's entirely a sidequest at this point, the main goal was to disassemble the patches

@atax1a well I had a peek at the "Patch File Format" documentation that's distributed with ResCompare, and it does not look like a fun time. At least it gives C struct definitions for the resources, which I guess is easier to hand-transcribe to Rez syntax than TMPLs are?

But apparently even a single resource's patch info is split across multiple resources in the patch application? Feels like the DeRez output for that still wouldn't be very readable, even if you have a good .r file for it...

@atax1a (this feels like the kind of format that requires a full custom parser and dumper tool, which could be interesting, but is definitely "sidequest" material :P)
@dgelessus yep. here's what a simple patch looks like when it's at home in its creator app, fwiw. coyote didn't catch the rabbit this time!