Cxbx-Reloaded / XbSymbolDatabase

Xbox Symbol Database library
MIT License
25 stars 10 forks source link

Create compact macro of VER_RANGE macro #175

Closed RadWolfie closed 1 year ago

RadWolfie commented 1 year ago

@PatrickvL made a suggestion to use a compact macro such as below and so on. #define VER_3911_UP VER_RANGE(3911, VER_MAX, VER_NONE, VER_NONE)

I like the compact macro idea which can be implement easily and replace unit test's database to be more align with above.

RadWolfie commented 1 year ago

UPDATE:

After first trial replacement, I noticed we had to manually add version number every time we need to lower/raise version detection level. Which isn't suitable until Patrick propose to make it simple as VER_RANGE_UP(from) one time macro usage. Then I noticed current VER_RANGE macro is somewhat not very clear. So, I propose to have prefix VER_RANGE macro with parameters method such as:

// Limit detection from low to max range of versions.
VER_RANGE_AND_UP(low);
// Limit detection between low to high range of versions.
// Some symbols may had been removed in titles with newer XDK build.
VER_RANGE_L2H(low, high);
// Limit detection between low1 to high1 and low2 to max range of versions.
// Some symbols may had been removed then later revert back.
VER_RANGE_L2H_AND_UP(low1, high1, low2);
// Limit detection between low1 to high1 and low2 to high2 range of versions.
// Some symbols may had been removed then later revert back and then revert again.
VER_RANGE_L2H_AND_L2H(low1, high1, low2, high2);

However, this does not need to be limited to macro. It can be change to C++ method. Since it will only apply to unit test software (C++).

UPDATE2:

Here's C++ method which will work as well but without parameters in a function.

static constexpr version_ranges VER_RANGE(uint16_t intro_start, uint16_t intro_end, uint16_t revive_start, uint16_t revive_end = VER_MAX)
{
    return version_ranges{
        .intro_start = intro_start,
        .intro_end = intro_end,
        .revive_start = revive_start,
        .revive_end = revive_end
    };
}
static constexpr version_ranges VER_RANGE(uint16_t intro_start, uint16_t intro_end = VER_MAX)
{
    return VER_RANGE(intro_start, intro_end, VER_NONE, VER_NONE);
}