Complete
over 2 years ago

Issue has been addressed.

No negative values in sdk/bin/api.mir

Ok, this falls squarely into the "I probably shouldn't be doing this" category, but while working on my monkeyc optimizer, I was looking for a definitive source for the values of all the Toybox enums and constants, and I came across api.mir. It seems to have every module, class, function, enum and const declared, and modulo some lines of the form [@file...;...], its pretty close to parseable monkeyc (the only real difference is that the keyword 'typedef' has been changed to 'type', as far as I can tell). Here's the Graphics.ColorValue section, for example:

        enum ColorValue {
            [@file = "api/Graphics.mb"; @line = 117; disableBackground = true; ]
            COLOR_DK_GREEN = 43520,
            [@file = "api/Graphics.mb"; @line = 93; disableBackground = true; ]
            COLOR_LT_GRAY = 11184810,
            [@file = "api/Graphics.mb"; @line = 99; disableBackground = true; ]
            COLOR_BLACK = 0,
            [@file = "api/Graphics.mb"; @line = 90; disableBackground = true; ]
            COLOR_WHITE = 16777215,
            [@file = "api/Graphics.mb"; @line = 111; disableBackground = true; ]
            COLOR_YELLOW = 16755200,
            [@file = "api/Graphics.mb"; @line = 123; disableBackground = true; ]
            COLOR_DK_BLUE = 255,
            [@file = "api/Graphics.mb"; @line = 96; disableBackground = true; ]
            COLOR_DK_GRAY = 5592405,
            [@file = "api/Graphics.mb"; @line = 102; disableBackground = true; ]
            COLOR_RED = 16711680,
            [@file = "api/Graphics.mb"; @line = 105; disableBackground = true; ]
            COLOR_DK_RED = 11141120,
            [@file = "api/Graphics.mb"; @line = 108; disableBackground = true; ]
            COLOR_ORANGE = 16733440,
            [@file = "api/Graphics.mb"; @line = 120; disableBackground = true; ]
            COLOR_BLUE = 43775,
            [@file = "api/Graphics.mb"; @line = 132; disableBackground = true; ]
            COLOR_TRANSPARENT = 1,
            [@file = "api/Graphics.mb"; @line = 114; disableBackground = true; ]
            COLOR_GREEN = 65280,
            [@file = "api/Graphics.mb"; @line = 126; disableBackground = true; ]
            COLOR_PURPLE = 11141375,
            [@file = "api/Graphics.mb"; @line = 129; disableBackground = true; ]
            COLOR_PINK = 16711935,
        }

Spot checking some colors, they all look correct. But COLOR_TRANSPARENT is listed as "1", rather than the correct value "-1". Closer inspection of the rest of the file reveals that every single constant that is supposed to be negative has the corresponding positive value.

So my tentative bug report is... api.mir contains the correct values for all the positive Toybox consts and enums, but seems to have accidentally dropped the minus sign for all the negative ones. And if it's not a bug, then my question is why does it contain the wrong values for the negative constants, given that its such an accurate reflection of the rest of the Toybox api?