Skip to content

Commit

Permalink
Rename Platform enums OS -> OS_TYPE and CPU -> CPU_TYPE to avoid Java…
Browse files Browse the repository at this point in the history
… 5 compiler issues.
  • Loading branch information
headius committed Feb 12, 2011
1 parent 158750e commit 611cce9
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/org/jruby/ext/ffi/Platform.java
Expand Up @@ -39,8 +39,8 @@
*
*/
public class Platform {
public static final CPU CPU = determineCPU();
public static final OS OS = determineOS();
public static final CPU_TYPE CPU = determineCPU();
public static final OS_TYPE OS = determineOS();

public static final String NAME = CPU + "-" + OS;
public static final String LIBPREFIX = OS == OS.WINDOWS ? "" : "lib";
Expand All @@ -57,7 +57,7 @@ public class Platform {
protected final Pattern libPattern;
private final int javaVersionMajor;

public enum OS {
public enum OS_TYPE {
DARWIN,
FREEBSD,
NETBSD,
Expand All @@ -72,7 +72,7 @@ public enum OS {
public String toString() { return name().toLowerCase(); }
}

public enum CPU {
public enum CPU_TYPE {
I386,
X86_64,
POWERPC,
Expand All @@ -89,22 +89,22 @@ private static final class SingletonHolder {
private static final Platform PLATFORM = determinePlatform(determineOS());
}

private static final OS determineOS() {
private static final OS_TYPE determineOS() {
String osName = System.getProperty("os.name").split(" ")[0].toLowerCase();
if (osName.startsWith("mac") || osName.startsWith("darwin")) {
return OS.DARWIN;
} else if (osName.startsWith("sunos") || osName.startsWith("solaris")) {
return OS.SOLARIS;
}
for (OS os : OS.values()) {
for (OS_TYPE os : OS.values()) {
if (osName.startsWith(os.toString().toLowerCase())) {
return os;
}
}
return OS.UNKNOWN;
}

private static final Platform determinePlatform(OS os) {
private static final Platform determinePlatform(OS_TYPE os) {
switch (os) {
case DARWIN:
return new Darwin();
Expand All @@ -121,7 +121,7 @@ private static final Platform determinePlatform(OS os) {
}
}

private static final CPU determineCPU() {
private static final CPU_TYPE determineCPU() {
String archString = System.getProperty("os.arch").toLowerCase();
if ("x86".equals(archString) || "i386".equals(archString) || "i86pc".equals(archString)) {
return CPU.I386;
Expand Down Expand Up @@ -172,7 +172,7 @@ private static final String determineLibExt() {
}
}

protected Platform(OS os) {
protected Platform(OS_TYPE os) {
int dataModel = Integer.getInteger("sun.arch.data.model");
if (dataModel != 32 && dataModel != 64) {
switch (CPU) {
Expand Down Expand Up @@ -237,7 +237,7 @@ public static final Platform getPlatform() {
*
* @return A <tt>OS</tt> value representing the current Operating System.
*/
public final OS getOS() {
public final OS_TYPE getOS() {
return OS;
}

Expand All @@ -246,7 +246,7 @@ public final OS getOS() {
*
* @return A <tt>CPU</tt> value representing the current processor architecture.
*/
public final CPU getCPU() {
public final CPU_TYPE getCPU() {
return CPU;
}

Expand All @@ -273,7 +273,7 @@ public final boolean isSupported() {
public static void createPlatformModule(Ruby runtime, RubyModule ffi) {
RubyModule module = ffi.defineModuleUnder("Platform");
Platform platform = Platform.getPlatform();
OS os = platform.getOS();
OS_TYPE os = platform.getOS();
module.defineConstant("ADDRESS_SIZE", runtime.newFixnum(platform.addressSize));
module.defineConstant("LONG_SIZE", runtime.newFixnum(platform.longSize));
module.defineConstant("OS", runtime.newString(OS.toString()));
Expand Down Expand Up @@ -380,18 +380,18 @@ public String mapLibraryName(String libName) {
return System.mapLibraryName(libName);
}
private static class Supported extends Platform {
public Supported(OS os) {
public Supported(OS_TYPE os) {
super(os);
}
}
private static class Unsupported extends Platform {
public Unsupported(OS os) {
public Unsupported(OS_TYPE os) {
super(os);
}
}
private static final class Default extends Platform {

public Default(OS os) {
public Default(OS_TYPE os) {
super(os);
}

Expand Down

0 comments on commit 611cce9

Please sign in to comment.