namedenums/namedenums.cpp

changeset 136
1c40bb4f8221
parent 135
8b9132fea327
equal deleted inserted replaced
135:8b9132fea327 136:1c40bb4f8221
339 339
340 SkipWhitespace (cp); 340 SkipWhitespace (cp);
341 341
342 if (*cp == '=') 342 if (*cp == '=')
343 { 343 {
344 // until I figure out how to deal with the duplicate value issue
345 // I should probably use a map but not today.
346 Error ("cannot have named enums that define enumerator values");
347
344 nenum.valuedefs = true; 348 nenum.valuedefs = true;
345 349
346 while (*cp != ',' && *cp != '\0') 350 while (*cp != ',' && *cp != '\0')
347 cp++; 351 cp++;
348 352
412 416
413 source.append ("};\n\n"); 417 source.append ("};\n\n");
414 418
415 source.append ("const char* Get%sString (%s value)\n" 419 source.append ("const char* Get%sString (%s value)\n"
416 "{\n" 420 "{\n"
417 "\treturn %sNames[value];\n" 421 "\treturn %sNames[long (value)];\n"
418 "}\n", 422 "}\n",
419 e.name.c_str(), e.name.c_str(), e.name.c_str()); 423 e.name.c_str(), e.name.c_str(), e.name.c_str());
420 } 424 }
421 else 425 else
422 { 426 {

mercurial