WerWolv / ImHex-Patterns

Hex patterns, include patterns and magic files for the use with the ImHex Hex Editor
https://github.com/WerWolv/ImHex
GNU General Public License v2.0
662 stars 176 forks source link

Replace get_attribute_value with get_attribute_argument #233

Closed ZwipZwapZapony closed 7 months ago

ZwipZwapZapony commented 7 months ago

In early 2023, builtin::std::core::get_attribute_value(pattern, attribute) was changed to builtin::std::core::get_attribute_argument(pattern, attribute, index), and a third parameter was added to that function. "includes/std/core.pat" was never updated for either of those things, causing compile errors when using std::core::get_attribute_value in a pattern.

This pull request updates that file to add std::core::get_attribute_argument(pattern, attribute, [index]) (with index defaulting to 0), and makes std::core::get_attribute_value show you an error telling you to use std::core::get_attribute_argument instead. (I would've made std::core::get_attribute_value use an index of 0, but given that it's been broken for over a year, I don't think that a lot of current patterns use it.)

(This pull request also updates the library documentation comments to have square brackets around optional arguments and list their default values, to correspond with https://github.com/WerWolv/Documentation/pull/12.)

\ Note that this is untested; ImHex tells me runtime error: Cannot cast value to type 'pattern' while evaluating a pattern where I try to use pattern-related functions. Therefore, I don't know whether index should default to 0 or to 1, so I just assumed 0.

WerWolv commented 7 months ago

Thanks a lot!