2021-12-09 19:15:21 +03:00
|
|
|
# note this is a "dynamic" include, output string will be used as source
|
|
|
|
|
2022-12-21 15:59:54 +03:00
|
|
|
# generates decode functions, ex:
|
|
|
|
# mp3/0 calls decode("mp3"; {})
|
|
|
|
# mp3/1 calls decode("mp3"; $opts)
|
|
|
|
# from_mp3/* same but throws error on decode error
|
2022-11-20 21:22:16 +03:00
|
|
|
|
|
|
|
[ _registry as $r
|
|
|
|
| $r.groups
|
2021-12-09 19:15:21 +03:00
|
|
|
| to_entries[]
|
|
|
|
# TODO: nicer way to skip "all" which also would override builtin all/*
|
2022-12-21 15:59:54 +03:00
|
|
|
# skip_decode_function is used to skip bits/bytes as they are special tobits/tobytes
|
2022-11-20 21:22:16 +03:00
|
|
|
| select(.key != "all" and ($r.formats[.key].skip_decode_function | not))
|
2021-12-09 19:15:21 +03:00
|
|
|
| "def \(.key)($opts): decode(\(.key | tojson); $opts);"
|
|
|
|
, "def \(.key): decode(\(.key | tojson); {});"
|
2022-12-21 15:59:54 +03:00
|
|
|
, "def from_\(.key)($opts): decode(\(.key | tojson); $opts) | if ._error then error(._error.error) end;"
|
|
|
|
, "def from_\(.key): from_\(.key)({});"
|
2021-12-09 19:15:21 +03:00
|
|
|
] | join("\n")
|