Interface Generator: Initialize static maps with initializer lists
authorJustin Dickow <jjdickow@gmail.com>
Thu, 27 Mar 2014 15:21:11 +0000 (11:21 -0400)
committerJustin Dickow <jjdickow@gmail.com>
Thu, 27 Mar 2014 15:21:11 +0000 (11:21 -0400)
Signed-off-by: Justin Dickow <jjdickow@gmail.com>
SDL_Core/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py

index a089140..eff5b1d 100755 (executable)
@@ -1430,22 +1430,19 @@ class CodeGenerator(object):
         u'''const std::map<${namespace}::${enum}::eType, '''
         u'''std::string> &TEnumSchemaItem<${namespace}::${enum}::eType>::'''
         u'''getEnumElementsStringRepresentation() {\n'''
-        u'''  static bool is_initialized = false;\n'''
         u'''  static std::map<${namespace}::${enum}::eType, '''
-        u'''std::string> enum_string_representation;\n'''
+        u'''std::string> enum_string_representation {\n'''
         u'''\n'''
-        u'''  if (false == is_initialized) {\n'''
         u'''${mapping}'''
         u'''\n'''
-        u'''    is_initialized = true;\n'''
-        u'''  }\n'''
+        u'''  };\n'''
         u'''\n'''
         u'''  return enum_string_representation;\n'''
         u'''}\n''')
 
     _enum_to_str_mapping_template = string.Template(
-        u'''enum_string_representation.insert(std::make_pair(${namespace}::'''
-        u'''${enum_name}::${enum_value}, "${string}"));''')
+        u'''{${namespace}::'''
+        u'''${enum_name}::${enum_value}, "${string}"},''')
 
     _struct_schema_item_template = string.Template(
         u'''utils::SharedPtr<ISchemaItem> struct_schema_item_${name} = '''