Skip to content

Commit

Permalink
Replace deprecated method.
Browse files Browse the repository at this point in the history
  • Loading branch information
letiemble committed Nov 1, 2014
1 parent c47281f commit 3d42143
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 69 deletions.
38 changes: 15 additions & 23 deletions libraries/Monobjc/MacOSVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,58 +30,50 @@ public enum MacOSVersion
/// <summary>
/// Default value
/// </summary>
MacOSUnrecognized = 0x0000,
MacOSUnrecognized = 0,
/// <summary>
/// Value for MacOS 10.0 (Cheetah)
/// </summary>
/// <remarks>
/// Here for compatibility reasons.
/// </remarks>
MacOS100 = 0x1000,
MacOS100 = 10 * 256 + 0,
/// <summary>
/// Value for MacOS 10.1 (Puma)
/// </summary>
/// <remarks>
/// Here for compatibility reasons.
/// </remarks>
MacOS101 = 0x1010,
MacOS101 = 10 * 256 + 1,
/// <summary>
/// Value for MacOS 10.2 (Jaguar)
/// </summary>
/// <remarks>
/// Here for compatibility reasons.
/// </remarks>
MacOS102 = 0x1020,
MacOS102 = 10 * 256 + 2,
/// <summary>
/// Value for MacOS 10.3 (Panther)
/// </summary>
/// <remarks>
/// Here for compatibility reasons.
/// </remarks>
MacOS103 = 0x1030,
MacOS103 = 10 * 256 + 3,
/// <summary>
/// Value for MacOS 10.4 (Tiger)
/// </summary>
MacOS104 = 0x1040,
MacOS104 = 10 * 256 + 4,
/// <summary>
/// Value for MacOS 10.5 (Leopard)
/// </summary>
MacOS105 = 0x1050,
MacOS105 = 10 * 256 + 5,
/// <summary>
/// Value for MacOS 10.6 (Snow Leopard)
/// </summary>
MacOS106 = 0x1060,
MacOS106 = 10 * 256 + 6,
/// <summary>
/// Value for MacOS 10.7 (Lion)
/// </summary>
MacOS107 = 0x1070,
MacOS107 = 10 * 256 + 7,
/// <summary>
/// Value for MacOS 10.8 (Mountain Lion)
/// </summary>
MacOS108 = 0x1080,
MacOS108 = 10 * 256 + 8,
/// <summary>
/// Value for MacOS 10.9 (Mavericks)
/// </summary>
MacOS109 = 0x1090,
MacOS109 = 10 * 256 + 9,
/// <summary>
/// Value for MacOS 10.9 (Yosemite)
/// </summary>
MacOS1010 = 10 * 256 + 10,
}
}
30 changes: 20 additions & 10 deletions native/Monobjc/sources/enumerations.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,52 +56,62 @@ typedef enum MonobjcLogDomain {
/** @brief Enumeration that holds values for Mac OS system version. */
typedef enum OSVersion {
/** @brief Default value. */
MACOS_Unrecognized = 0x0000,
MACOS_Unrecognized = 0,
/**
* @brief Value for MacOS 10.0 (Cheetah).
* @remark Here for compatibility reasons.
*/
MACOS_10_0 = 0x1000,
MACOS_10_0 = 10 * 256 + 0,
/**
* @brief Value for MacOS 10.1 (Puma).
* @remark Here for compatibility reasons.
*/
MACOS_10_1 = 0x1010,
MACOS_10_1 = 10 * 256 + 1,
/**
* @brief Value for MacOS 10.2 (Jaguar).
* @remark Here for compatibility reasons.
*/
MACOS_10_2 = 0x1020,
MACOS_10_2 = 10 * 256 + 2,
/**
* @brief Value for MacOS 10.3 (Panther).
* @remark Here for compatibility reasons.
*/
MACOS_10_3 = 0x1030,
MACOS_10_3 = 10 * 256 + 3,
/**
* @brief Value for MacOS 10.4 (Tiger).
* @remark This is no longer a supported platform.
*/
MACOS_10_4 = 0x1040,
MACOS_10_4 = 10 * 256 + 4,
/**
* @brief Value for MacOS 10.5 (Leopard).
* @remark This is a supported platform.
*/
MACOS_10_5 = 0x1050,
MACOS_10_5 = 10 * 256 + 5,
/**
* @brief Value for MacOS 10.6 (Snow Leopard).
* @remark This is a supported platform.
*/
MACOS_10_6 = 0x1060,
MACOS_10_6 = 10 * 256 + 6,
/**
* @brief Value for MacOS 10.7 (Lion).
* @remark This is a supported platform.
*/
MACOS_10_7 = 0x1070,
MACOS_10_7 = 10 * 256 + 7,
/**
* @brief Value for MacOS 10.8 (Mountain Lion).
* @remark This is a supported platform.
*/
MACOS_10_8 = 0x1080,
MACOS_10_8 = 10 * 256 + 8,
/**
* @brief Value for MacOS 10.9 (Mavericks).
* @remark This is a supported platform.
*/
MACOS_10_9 = 10 * 256 + 9,
/**
* @brief Value for MacOS 10.10 (Yosemite).
* @remark This is a supported platform.
*/
MACOS_10_10 = 10 * 256 + 10,
} OSVersion;

/**
Expand Down
30 changes: 1 addition & 29 deletions native/Monobjc/sources/icalls/icalls-Monobjc.Runtime.Platform.mm
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,7 @@
*/
OSVersion icall_Monobjc_Runtime_Platform_GetOSVersion(void) {
SInt32 version = monobjc_get_os_version();

if (version < MACOS_10_0) {
return MACOS_Unrecognized;
}
if (version < MACOS_10_1) {
return MACOS_10_0;
}
if (version < MACOS_10_2) {
return MACOS_10_1;
}
if (version < MACOS_10_3) {
return MACOS_10_2;
}
if (version < MACOS_10_4) {
return MACOS_10_3;
}
if (version < MACOS_10_5) {
return MACOS_10_4;
}
if (version < MACOS_10_6) {
return MACOS_10_5;
}
if (version < MACOS_10_7) {
return MACOS_10_6;
}
if (version < MACOS_10_8) {
return MACOS_10_7;
}
return MACOS_10_8;
return (OSVersion) version;
}

/**
Expand Down
9 changes: 4 additions & 5 deletions native/Monobjc/sources/support-os.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@

SInt32 monobjc_get_os_version() {
if (!os_version) {
if (Gestalt(gestaltSystemVersion, &os_version) < 0) {
LOG_ERROR(MONOBJC_DOMAIN_GENERAL, "Cannot retrieve the system version.");
}
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
os_version = version.majorVersion * 256 + version.minorVersion;
}
return os_version;
}
Expand All @@ -63,10 +62,10 @@ SInt32 monobjc_get_os_version() {

int monobjc_are_associated_objects_available() {
SInt32 version = monobjc_get_os_version();
return (version >= 0x1060);
return (version >= MACOS_10_6);
}

int monobjc_are_blocks_available() {
SInt32 version = monobjc_get_os_version();
return (version >= 0x1060);
return (version >= MACOS_10_6);
}
5 changes: 4 additions & 1 deletion native/monobjc-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ case $(uname -r) in
12.*)
"/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/monobjc-10.8/runtime" $@
;;
13.*)
"/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/monobjc-10.9/runtime" $@
;;
*)
"/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/monobjc-10.8/runtime" $@
"/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/monobjc-10.9/runtime" $@
;;
esac

0 comments on commit 3d42143

Please sign in to comment.