The OpenD Programming Language

1 /*
2 
3 Boost Software License - Version 1.0 - August 17th, 2003
4 
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
11 
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 
27 */
28 module derelict.util.system;
29 
30 static if((void*).sizeof == 8) {
31 	enum Derelict_Arch_64 = true;
32 	enum Derelict_Arch_32 = false;
33 }
34 else {
35 	enum Derelict_Arch_64 = false;
36 	enum Derelict_Arch_32 = true;
37 }
38 
39 version(Windows) enum Derelict_OS_Windows = true;
40 else enum Derelict_OS_Windows = false;
41 
42 version(OSX) enum Derelict_OS_Mac = true;
43 else enum Derelict_OS_Mac = false;
44 
45 version(linux) enum Derelict_OS_Linux = true;
46 else enum Derelict_OS_Linux = false;
47 
48 version(Posix) enum Derelict_OS_Posix = true;
49 else enum Derelict_OS_Posix = false;
50 
51 version(Android) enum Derelict_OS_Android = true;
52 else enum Derelict_OS_Android = false;
53 
54 // TODO
55 enum Derelict_OS_iOS = false;
56 enum Derelict_OS_WinRT = false;
57 
58 version(FreeBSD) {
59 	enum Derelict_OS_AnyBSD = true;
60 	enum Derelict_OS_FreeBSD = true;
61 	enum Derelict_OS_OpenBSD = false;
62 	enum Derelict_OS_OtherBSD = false;
63 } else version(OpenBSD) {
64 	enum Derelict_OS_AnyBSD = true;
65 	enum Derelict_OS_FreeBSD = false;
66 	enum Derelict_OS_OpenBSD = true;
67 	enum Derelict_OS_OtherBSD = false;
68 } else version(BSD) {
69 	enum Derelict_OS_AnyBSD = true;
70 	enum Derelict_OS_FreeBSD = false;
71 	enum Derelict_OS_OpenBSD = false;
72 	enum Derelict_OS_OtherBSD = true;
73 } else {
74 	enum Derelict_OS_AnyBSD = false;
75 	enum Derelict_OS_FreeBSD = false;
76 	enum Derelict_OS_OpenBSD = false;
77 	enum Derelict_OS_OtherBSD = false;
78 }
79 
80 static if(__VERSION__ < 2066) enum nogc = 1;
81 
82 enum MakeEnum(EnumType, string fqnEnumType = EnumType.stringof) = (){
83   string MakeEnum = "enum {";
84   foreach(m;__traits(allMembers, EnumType))
85   {
86       MakeEnum ~= m ~ " = " ~ fqnEnumType ~ "." ~ m ~ ",";
87   }
88   MakeEnum  ~= "}";
89   return MakeEnum;
90 }();