Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 91092a6

Browse files
committed
[[ OSVersion ]] Add functions to (un)pack system OS version
This patch adds functions to set & access the system OS version number: MCOSVersionMake(pMajor, pMinor, pBugfix) Pack the given version number components into a single 32-bit value. MCOSVersionGetMajor(pVersion) Unpack the major version number component from the packed value MCOSVersionGetMinor(pVersion) Unpack the minor version number component from the packed value MCOSVersionGetBugfix(pVersion) Unpack the bugfix version number component from the packed value. Existing comparisons of the global MCmajorosversion have been updated to construct a packed version number using MCOSVersionMake to compare with instead of using fixed hexadecimal values.
1 parent 3f5e984 commit 91092a6

37 files changed

+122
-103
lines changed

engine/src/button.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ void MCButton::makemenu(sublist *bstack, int2 &stackdepth, uint2 menuflags, MCFo
22422242

22432243
uint2 ty;
22442244
uint2 menuwidth, menuheight;
2245-
if (isxp && MCmajorosversion >= 0x0600)
2245+
if (isxp && MCmajorosversion >= MCOSVersionMake(6,0,0))
22462246
{
22472247
ty = 3;
22482248
m -> maxwidth += 22 + 4 + 2 + 4 + 17; // Icon - pad - Gutter - pad - ... - Submenu

engine/src/buttondraw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
106106
Boolean isstdbtn = standardbtn();
107107
uint2 i;
108108
Boolean noback = isstdbtn && !getcindex(DI_BACK, i) && !getpindex(DI_BACK,i);
109-
bool t_isvista = MCmajorosversion >= 0x0600 && MCcurtheme != NULL;
109+
bool t_isvista = MCmajorosversion >= MCOSVersionMake(6,0,0) && MCcurtheme != NULL;
110110

111111
bool t_themed_menu = false;
112112
bool t_use_alpha_layer = false;
@@ -553,7 +553,7 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
553553
#ifdef _MACOSX
554554
// FG-2014-10-29: [[ Bugfix 13842 ]] On Yosemite, glowing buttons
555555
// should draw with white text.
556-
if (IsMacLFAM() && MCmajorosversion >= 0x10A0 && MCaqua
556+
if (IsMacLFAM() && MCmajorosversion >= MCOSVersionMake(10,10,0) && MCaqua
557557
&& !(flags & F_DISABLED) && isstdbtn && getstyleint(flags) == F_STANDARD
558558
&& ((state & CS_HILITED) || (state & CS_SHOW_DEFAULT))
559559
&& rect.height <= 24 && MCappisactive)
@@ -1783,7 +1783,7 @@ void MCButton::drawstandardbutton(MCDC *dc, MCRectangle &srect)
17831783

17841784
// On Yosemite, the default button theme is only suppressed when the
17851785
// app is not active.
1786-
if (getflag(F_DEFAULT) && IsMacLFAM() && MCaqua && MCmajorosversion >= 0x10A0)
1786+
if (getflag(F_DEFAULT) && IsMacLFAM() && MCaqua && MCmajorosversion >= MCOSVersionMake(10,10,0))
17871787
{
17881788
winfo.state &= ~WTHEME_STATE_SUPPRESSDEFAULT;
17891789
winfo.state |= WTHEME_STATE_HASDEFAULT;

engine/src/dskmac.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ static bool same_var(const char *p_left, const char *p_right)
10171017
static char **fix_environ(void)
10181018
{
10191019
char **t_new_environ;
1020-
if (MCmajorosversion > 0x1090)
1020+
if (MCmajorosversion > MCOSVersionMake(10,9,0))
10211021
{
10221022
// Build a new environ, making sure that each var only takes the
10231023
// first definition in the list. We don't have to care about memory
@@ -2425,7 +2425,7 @@ struct MCMacSystemService: public MCMacSystemServiceInterface//, public MCMacDes
24252425

24262426
// On Snow Leopard check for a coercion to a file list first as otherwise
24272427
// we get a bad URL!
2428-
if (MCmajorosversion >= 0x1060)
2428+
if (MCmajorosversion >= MCOSVersionMake(10,6,0))
24292429
{
24302430
// SN-2014-10-07: [[ Bug 13587 ]] fetch_as_as_fsref_list updated to return an MCList
24312431
MCAutoListRef t_list;
@@ -2784,22 +2784,12 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
27842784

27852785
MCinfinity = HUGE_VAL;
27862786

2787-
// SN-2014-10-08: [[ YosemiteUpdate ]] gestaltSystemVersion stops to 9 after any Minor/Bugfix >= 10
2788-
// We want to keep the same way the os version is built, which is 0xMMmb
2789-
// - MM reads the decimal major version number
2790-
// - m reads the hexadecimal minor version number
2791-
// - b reads the hexadecimal bugfix number.
27922787
SInt32 t_major, t_minor, t_bugfix;
27932788
if (Gestalt(gestaltSystemVersionMajor, &t_major) == noErr &&
27942789
Gestalt(gestaltSystemVersionMinor, &t_minor) == noErr &&
27952790
Gestalt(gestaltSystemVersionBugFix, &t_bugfix) == noErr)
27962791
{
2797-
if (t_major < 10)
2798-
MCmajorosversion = t_major * 0x100;
2799-
else
2800-
MCmajorosversion = (t_major / 10) * 0x1000 + (t_major - 10) * 0x100;
2801-
MCmajorosversion += t_minor * 0x10;
2802-
MCmajorosversion += t_bugfix * 0x1;
2792+
MCmajorosversion = MCOSVersionMake(t_major, t_minor, t_bugfix);
28032793
}
28042794

28052795
MCaqua = True; // Move to MCScreenDC

engine/src/dskw32.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ bool MCS_registry_root_to_hkey(MCStringRef p_root, HKEY& r_hkey, uint32_t& x_acc
365365
if (MCStringIsEqualToCString(p_root, Regkeys[i].token, kMCCompareCaseless))
366366
{
367367
r_hkey = Regkeys[i].key;
368-
if (MCmajorosversion >= 0x0501)
368+
if (MCmajorosversion >= MCOSVersionMake(5,1,0))
369369
x_access_mode |= Regkeys[i].mode;
370370
return true;
371371
}
@@ -1551,15 +1551,15 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
15511551
memset(&osv, 0, sizeof(OSVERSIONINFOA));
15521552
osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
15531553
GetVersionExA(&osv);
1554-
MCmajorosversion = osv . dwMajorVersion << 8 | osv . dwMinorVersion;
1554+
MCmajorosversion = MCOSVersionMake(osv.dwMajorVersion, osv.dwMinorVersion, 0);
15551555

15561556
// MW-2012-09-19: [[ Bug ]] Adjustment to tooltip metrics for Windows.
1557-
if (MCmajorosversion >= 0x0500)
1557+
if (MCmajorosversion >= MCOSVersionMake(5,0,0))
15581558
{
15591559
MCttsize = 11;
15601560
MCValueAssign(MCttfont, MCSTR("Tahoma"));
15611561
}
1562-
else if (MCmajorosversion >= 0x0600)
1562+
else if (MCmajorosversion >= MCOSVersionMake(6,0,0))
15631563
{
15641564
MCttsize = 11;
15651565
MCValueAssign(MCttfont, MCSTR("Segoe UI"));
@@ -1617,7 +1617,7 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
16171617

16181618
virtual bool GetVersion(MCStringRef& r_string)
16191619
{
1620-
return MCStringFormat(r_string, "NT %d.%d", (MCmajorosversion >> 8) & 0xFF, MCmajorosversion & 0xFF);
1620+
return MCStringFormat(r_string, "NT %d.%d", MCOSVersionGetMajor(MCmajorosversion), MCOSVersionGetMinor(MCmajorosversion));
16211621
}
16221622

16231623
virtual bool GetMachine(MCStringRef& r_string)
@@ -3004,7 +3004,7 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
30043004
t_cmdline = (MCStringRef) MCValueRetain(MCNameGetString(p_name));
30053005

30063006
// There's no such thing as Elevation before Vista (majorversion 6)
3007-
if (!p_elevated || MCmajorosversion < 0x0600)
3007+
if (!p_elevated || MCmajorosversion < MCOSVersionMake(6,0,0))
30083008
{
30093009
HANDLE hChildStdinRd = NULL;
30103010
HANDLE hChildStdoutWr = NULL;

engine/src/globals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ bool X_open(int argc, MCStringRef argv[], MCStringRef envp[])
10921092

10931093
#if defined(_MACOSX) && defined(FEATURE_QUICKTIME)
10941094
// MW-2014-07-21: Make AVFoundation the default on 10.8 and above.
1095-
if (MCmajorosversion < 0x1080)
1095+
if (MCmajorosversion < MCOSVersionMake(10,8,0))
10961096
{
10971097
MCdontuseQT = False;
10981098
MCdontuseQTeffects = False;

engine/src/mac-core.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,7 @@ void MCMacPlatformHandleMouseCursorChange(MCPlatformWindowRef p_window)
17611761
// If we are on Lion+ then check to see if the mouse location is outside
17621762
// of any of the system tracking rects (used for resizing etc.)
17631763
extern uint4 MCmajorosversion;
1764-
if (MCmajorosversion >= 0x1070)
1764+
if (MCmajorosversion >= MCOSVersionMake(10,7,0))
17651765
{
17661766
// MW-2014-06-11: [[ Bug 12437 ]] Make sure we only check tracking rectangles if we have
17671767
// a resizable frame.

engine/src/mac-dialog.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ void MCPlatformBeginFolderOrFileDialog(MCPlatformFileDialogKind p_kind, MCPlatfo
592592
else
593593
{
594594
extern uint4 MCmajorosversion;
595-
if (MCmajorosversion >= 0x10B0 && p_kind != kMCPlatformFileDialogKindSave)
595+
if (MCmajorosversion >= MCOSVersionMake(10,11,0) && p_kind != kMCPlatformFileDialogKindSave)
596596
[t_panel setMessage:MCStringConvertToAutoreleasedNSString(p_prompt)];
597597
else
598598
[t_panel setTitle: MCStringConvertToAutoreleasedNSString(p_prompt)];

engine/src/mac-theme.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
// Returns the name of the legacy font
4141
static NSString* get_legacy_font_name()
4242
{
43-
if (MCmajorosversion < 0x10A0)
43+
if (MCmajorosversion < MCOSVersionMake(10,10,0))
4444
return @"Lucida Grande";
45-
if (MCmajorosversion > 0x10B0)
45+
if (MCmajorosversion > MCOSVersionMake(10,11,0))
4646
return @"San Francisco";
4747
else
4848
return @"Helvetica Neue";

engine/src/mblhandlers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3596,7 +3596,7 @@ Exec_stat MCHandleIPhonePickMedia(void *context, MCParameter *p_parameters)
35963596
else if (MCCStringEqualCaseless(t_option_list, "audiobook"))
35973597
t_media_types += kMCMediaTypeAudiobooks;
35983598
#ifdef __IPHONE_5_0
3599-
if (MCmajorosversion >= 500)
3599+
if (MCmajorosversion >= MCOSVersionMake(5,0,0))
36003600
{
36013601
if (MCCStringEqualCaseless(t_option_list, "movie"))
36023602
t_media_types += kMCMediaTypeMovies;
@@ -3616,7 +3616,7 @@ Exec_stat MCHandleIPhonePickMedia(void *context, MCParameter *p_parameters)
36163616
{
36173617
t_media_types = MCMediaTypeFromString(MCSTR("podcast, songs, audiobook"));;
36183618
#ifdef __IPHONE_5_0
3619-
if (MCmajorosversion >= 500)
3619+
if (MCmajorosversion >= MCOSVersionMake(5,0,0))
36203620
t_media_types += MCMediaTypeFromString(MCSTR("movies, tv, videoPodcasts, musicVideos, videoITunesU"));;
36213621
#endif
36223622
}

engine/src/mbliphone.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ virtual uint64_t GetFileSize(void)
641641

642642
// MM-2012-11-22: [[ Bug 10540 ]] - For iOS 6, use MCStdioFileDescriptorHandle for stdio streams.
643643
// This just wraps NSLog for output. No input supported.
644-
if (MCmajorosversion < 600)
644+
if (MCmajorosversion < MCOSVersionMake(6,0,0))
645645
t_handle = new MCStdioFileHandle(t_stream);
646646
else
647647
t_handle = new MCStdioFileDescriptorHandle();

0 commit comments

Comments
 (0)