comparison Resources/EmbedResources.py @ 49:e1a3ae0dadf3

renaming of resources
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Sep 2012 15:38:08 +0200
parents a56b6a8b89ba
children 601ee9b7f2c7
comparison
equal deleted inserted replaced
48:0a04c70747d9 49:e1a3ae0dadf3
86 header.write(""" 86 header.write("""
87 #pragma once 87 #pragma once
88 88
89 #include <string> 89 #include <string>
90 90
91 namespace Palantir 91 namespace Palanthir
92 { 92 {
93 namespace EmbeddedResources 93 namespace EmbeddedResources
94 { 94 {
95 enum FileResourceId 95 enum FileResourceId
96 { 96 {
170 170
171 cpp = open(sys.argv[1] + '.cpp', 'w') 171 cpp = open(sys.argv[1] + '.cpp', 'w')
172 172
173 cpp.write(""" 173 cpp.write("""
174 #include "%s.h" 174 #include "%s.h"
175 #include "%s/Core/PalantirException.h" 175 #include "%s/Core/PalanthirException.h"
176 176
177 #include <stdint.h> 177 #include <stdint.h>
178 #include <string.h> 178 #include <string.h>
179 179
180 namespace Palantir 180 namespace Palanthir
181 { 181 {
182 namespace EmbeddedResources 182 namespace EmbeddedResources
183 { 183 {
184 """ % (os.path.basename(sys.argv[1]), 184 """ % (os.path.basename(sys.argv[1]),
185 os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))) 185 os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))))
209 cpp.write(' case %s:\n' % name) 209 cpp.write(' case %s:\n' % name)
210 cpp.write(' return resource%dBuffer;\n' % resources[name]['Index']) 210 cpp.write(' return resource%dBuffer;\n' % resources[name]['Index'])
211 211
212 cpp.write(""" 212 cpp.write("""
213 default: 213 default:
214 throw PalantirException(ErrorCode_ParameterOutOfRange); 214 throw PalanthirException(ErrorCode_ParameterOutOfRange);
215 } 215 }
216 } 216 }
217 217
218 size_t GetFileResourceSize(FileResourceId id) 218 size_t GetFileResourceSize(FileResourceId id)
219 { 219 {
226 cpp.write(' case %s:\n' % name) 226 cpp.write(' case %s:\n' % name)
227 cpp.write(' return resource%dSize;\n' % resources[name]['Index']) 227 cpp.write(' return resource%dSize;\n' % resources[name]['Index'])
228 228
229 cpp.write(""" 229 cpp.write("""
230 default: 230 default:
231 throw PalantirException(ErrorCode_ParameterOutOfRange); 231 throw PalanthirException(ErrorCode_ParameterOutOfRange);
232 } 232 }
233 } 233 }
234 """) 234 """)
235 235
236 236
251 cpp.write(' case %s:\n' % name) 251 cpp.write(' case %s:\n' % name)
252 isFirst = True 252 isFirst = True
253 for path in resources[name]['Files']: 253 for path in resources[name]['Files']:
254 cpp.write(' if (!strcmp(path, "%s"))\n' % path) 254 cpp.write(' if (!strcmp(path, "%s"))\n' % path)
255 cpp.write(' return resource%dBuffer;\n' % resources[name]['Files'][path]['Index']) 255 cpp.write(' return resource%dBuffer;\n' % resources[name]['Files'][path]['Index'])
256 cpp.write(' throw PalantirException("Unknown path in a directory resource");\n\n') 256 cpp.write(' throw PalanthirException("Unknown path in a directory resource");\n\n')
257 257
258 cpp.write(""" default: 258 cpp.write(""" default:
259 throw PalantirException(ErrorCode_ParameterOutOfRange); 259 throw PalanthirException(ErrorCode_ParameterOutOfRange);
260 } 260 }
261 } 261 }
262 262
263 size_t GetDirectoryResourceSize(DirectoryResourceId id, const char* path) 263 size_t GetDirectoryResourceSize(DirectoryResourceId id, const char* path)
264 { 264 {
271 cpp.write(' case %s:\n' % name) 271 cpp.write(' case %s:\n' % name)
272 isFirst = True 272 isFirst = True
273 for path in resources[name]['Files']: 273 for path in resources[name]['Files']:
274 cpp.write(' if (!strcmp(path, "%s"))\n' % path) 274 cpp.write(' if (!strcmp(path, "%s"))\n' % path)
275 cpp.write(' return resource%dSize;\n' % resources[name]['Files'][path]['Index']) 275 cpp.write(' return resource%dSize;\n' % resources[name]['Files'][path]['Index'])
276 cpp.write(' throw PalantirException("Unknown path in a directory resource");\n\n') 276 cpp.write(' throw PalanthirException("Unknown path in a directory resource");\n\n')
277 277
278 cpp.write(""" default: 278 cpp.write(""" default:
279 throw PalantirException(ErrorCode_ParameterOutOfRange); 279 throw PalanthirException(ErrorCode_ParameterOutOfRange);
280 } 280 }
281 } 281 }
282 """) 282 """)
283 283
284 284