@@ -63,86 +63,14 @@ bool Platform::set(Type t)
6363 return true ;
6464 case Type::Win32W:
6565 case Type::Win32A:
66- type = t;
67- sizeof_bool = 1 ; // 4 in Visual C++ 4.2
68- sizeof_short = 2 ;
69- sizeof_int = 4 ;
70- sizeof_long = 4 ;
71- sizeof_long_long = 8 ;
72- sizeof_float = 4 ;
73- sizeof_double = 8 ;
74- sizeof_long_double = 8 ;
75- sizeof_wchar_t = 2 ;
76- sizeof_size_t = 4 ;
77- sizeof_pointer = 4 ;
78- defaultSign = ' \0 ' ;
79- char_bit = 8 ;
80- short_bit = char_bit * sizeof_short;
81- int_bit = char_bit * sizeof_int;
82- long_bit = char_bit * sizeof_long;
83- long_long_bit = char_bit * sizeof_long_long;
84- return true ;
8566 case Type::Win64:
86- type = t;
87- sizeof_bool = 1 ;
88- sizeof_short = 2 ;
89- sizeof_int = 4 ;
90- sizeof_long = 4 ;
91- sizeof_long_long = 8 ;
92- sizeof_float = 4 ;
93- sizeof_double = 8 ;
94- sizeof_long_double = 8 ;
95- sizeof_wchar_t = 2 ;
96- sizeof_size_t = 8 ;
97- sizeof_pointer = 8 ;
98- defaultSign = ' \0 ' ;
99- char_bit = 8 ;
100- short_bit = char_bit * sizeof_short;
101- int_bit = char_bit * sizeof_int;
102- long_bit = char_bit * sizeof_long;
103- long_long_bit = char_bit * sizeof_long_long;
104- return true ;
10567 case Type::Unix32:
106- type = t;
107- sizeof_bool = 1 ;
108- sizeof_short = 2 ;
109- sizeof_int = 4 ;
110- sizeof_long = 4 ;
111- sizeof_long_long = 8 ;
112- sizeof_float = 4 ;
113- sizeof_double = 8 ;
114- sizeof_long_double = 12 ;
115- sizeof_wchar_t = 4 ;
116- sizeof_size_t = 4 ;
117- sizeof_pointer = 4 ;
118- defaultSign = ' \0 ' ;
119- char_bit = 8 ;
120- short_bit = char_bit * sizeof_short;
121- int_bit = char_bit * sizeof_int;
122- long_bit = char_bit * sizeof_long;
123- long_long_bit = char_bit * sizeof_long_long;
124- return true ;
12568 case Type::Unix64:
12669 type = t;
127- sizeof_bool = 1 ;
128- sizeof_short = 2 ;
129- sizeof_int = 4 ;
130- sizeof_long = 8 ;
131- sizeof_long_long = 8 ;
132- sizeof_float = 4 ;
133- sizeof_double = 8 ;
134- sizeof_long_double = 16 ;
135- sizeof_wchar_t = 4 ;
136- sizeof_size_t = 8 ;
137- sizeof_pointer = 8 ;
138- defaultSign = ' \0 ' ;
139- char_bit = 8 ;
140- short_bit = char_bit * sizeof_short;
141- int_bit = char_bit * sizeof_int;
142- long_bit = char_bit * sizeof_long;
143- long_long_bit = char_bit * sizeof_long_long;
70+ // read from platform file
14471 return true ;
14572 case Type::File:
73+ type = t;
14674 // sizes are not set.
14775 return false ;
14876 }
@@ -152,40 +80,73 @@ bool Platform::set(Type t)
15280
15381bool Platform::set (const std::string& platformstr, std::string& errstr, const std::vector<std::string>& paths, bool debug)
15482{
155- if (platformstr == " win32A" )
156- set (Type::Win32A);
157- else if (platformstr == " win32W" )
158- set (Type::Win32W);
159- else if (platformstr == " win64" )
160- set (Type::Win64);
161- else if (platformstr == " unix32" )
162- set (Type::Unix32);
163- else if (platformstr == " unix64" )
164- set (Type::Unix64);
165- else if (platformstr == " native" )
166- set (Type::Native);
167- else if (platformstr == " unspecified" )
168- set (Type::Unspecified);
83+ Type t;
84+ std::string platformFile;
85+
86+ if (platformstr == " win32A" ) {
87+ // TODO: deprecate
88+ // std::cout << "Platform 'win32A' is deprecated and will be removed in a future version. Please use 'win32a' instead." << std::endl;
89+ t = Type::Win32A;
90+ platformFile = " win32a" ;
91+ }
92+ else if (platformstr == " win32a" ) {
93+ t = Type::Win32A;
94+ platformFile = platformstr;
95+ }
96+ else if (platformstr == " win32W" ) {
97+ // TODO: deprecate
98+ // std::cout << "Platform 'win32W' is deprecated and will be removed in a future version. Please use 'win32w' instead." << std::endl;
99+ t = Type::Win32W;
100+ platformFile = " win32w" ;
101+ }
102+ else if (platformstr == " win32w" ) {
103+ t = Type::Win32W;
104+ platformFile = platformstr;
105+ }
106+ else if (platformstr == " win64" ) {
107+ t = Type::Win64;
108+ platformFile = platformstr;
109+ }
110+ else if (platformstr == " unix32" ) {
111+ t = Type::Unix32;
112+ platformFile = platformstr;
113+ }
114+ else if (platformstr == " unix64" ) {
115+ t = Type::Unix64;
116+ platformFile = platformstr;
117+ }
118+ else if (platformstr == " native" ) {
119+ t = Type::Native;
120+ }
121+ else if (platformstr == " unspecified" ) {
122+ t = Type::Unspecified;
123+ }
169124 else if (paths.empty ()) {
170125 errstr = " unrecognized platform: '" + platformstr + " ' (no lookup)." ;
171126 return false ;
172127 }
173128 else {
129+ t = Type::File;
130+ platformFile = platformstr;
131+ }
132+
133+ if (!platformFile.empty ()) {
174134 bool found = false ;
175135 for (const std::string& path : paths) {
176136 if (debug)
177- std::cout << " looking for platform '" + platformstr + " ' in '" + path + " '" << std::endl;
178- if (loadFromFile (path.c_str (), platformstr , debug)) {
137+ std::cout << " looking for platform '" + platformFile + " ' in '" + path + " '" << std::endl;
138+ if (loadFromFile (path.c_str (), platformFile , debug)) {
179139 found = true ;
180140 break ;
181141 }
182142 }
183143 if (!found) {
184- errstr = " unrecognized platform: '" + platformstr + " '." ;
144+ errstr = " unrecognized platform: '" + platformFile + " '." ;
185145 return false ;
186146 }
187147 }
188148
149+ set (t);
189150 return true ;
190151}
191152
@@ -248,6 +209,7 @@ bool Platform::loadFromXmlDocument(const tinyxml2::XMLDocument *doc)
248209 if (!rootnode || std::strcmp (rootnode->Name (), " platform" ) != 0 )
249210 return false ;
250211
212+ // TODO: warn about missing fields
251213 bool error = false ;
252214 for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement (); node; node = node->NextSiblingElement ()) {
253215 const char * name = node->Name ();
@@ -293,7 +255,6 @@ bool Platform::loadFromXmlDocument(const tinyxml2::XMLDocument *doc)
293255 long_bit = char_bit * sizeof_long;
294256 long_long_bit = char_bit * sizeof_long_long;
295257
296- type = Type::File;
297258 return !error;
298259}
299260
0 commit comments