| 39 | |
| 40 | |
| 41 | public class Platform { |
| 42 | static DefaultPlatform inst; |
| 43 | |
| 44 | static Map<Integer, String> platformNames = new HashMap<>(); |
| 45 | static { |
| 46 | platformNames.put(PConstants.WINDOWS, "windows"); //$NON-NLS-1$ |
| 47 | platformNames.put(PConstants.MACOSX, "macosx"); //$NON-NLS-1$ |
| 48 | platformNames.put(PConstants.LINUX, "linux"); //$NON-NLS-1$ |
| 49 | } |
| 50 | |
| 51 | static Map<String, Integer> platformIndices = new HashMap<>(); |
| 52 | static { |
| 53 | platformIndices.put("windows", PConstants.WINDOWS); //$NON-NLS-1$ |
| 54 | platformIndices.put("macosx", PConstants.MACOSX); //$NON-NLS-1$ |
| 55 | platformIndices.put("linux", PConstants.LINUX); //$NON-NLS-1$ |
| 56 | } |
| 57 | |
| 58 | /** How many bits this machine is */ |
| 59 | static int nativeBits; |
| 60 | static { |
| 61 | nativeBits = 32; // perhaps start with 32 |
| 62 | String bits = System.getProperty("sun.arch.data.model"); //$NON-NLS-1$ |
| 63 | if (bits != null) { |
| 64 | if (bits.equals("64")) { //$NON-NLS-1$ |
| 65 | nativeBits = 64; |
| 66 | } |
| 67 | } else { |
| 68 | // if some other strange vm, maybe try this instead |
| 69 | if (System.getProperty("java.vm.name").contains("64")) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 70 | nativeBits = 64; |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | |
| 76 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
| 77 | |
| 78 | |
| 79 | static public void init() { |
| 80 | try { |
| 81 | Class<?> platformClass = Class.forName("processing.app.Platform"); //$NON-NLS-1$ |
| 82 | if (Platform.isMacOS()) { |
| 83 | platformClass = Class.forName("processing.app.platform.MacPlatform"); //$NON-NLS-1$ |
| 84 | } else if (Platform.isWindows()) { |
| 85 | platformClass = Class.forName("processing.app.platform.WindowsPlatform"); //$NON-NLS-1$ |
| 86 | } else if (Platform.isLinux()) { |
| 87 | platformClass = Class.forName("processing.app.platform.LinuxPlatform"); //$NON-NLS-1$ |
| 88 | } |
| 89 | inst = (DefaultPlatform) platformClass.getDeclaredConstructor().newInstance(); |
| 90 | } catch (Exception e) { |
| 91 | Messages.showError("Problem Setting the Platform", |
| 92 | "An unknown error occurred while trying to load\n" + |
| 93 | "platform-specific code for your machine.", e); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | |
| 98 | static public void initBase(Base base) throws Exception { |