OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from code import Code | 5 from code import Code |
6 from model import PropertyType | 6 from model import PropertyType |
7 import cpp_util | 7 import cpp_util |
8 import schema_util | 8 import schema_util |
9 import util_cc_helper | 9 import util_cc_helper |
10 from cpp_namespace_environment import CppNamespaceEnvironment | 10 from cpp_namespace_environment import CppNamespaceEnvironment |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 c.Append('// static') | 966 c.Append('// static') |
967 maybe_namespace = '' if cpp_namespace is None else '%s::' % cpp_namespace | 967 maybe_namespace = '' if cpp_namespace is None else '%s::' % cpp_namespace |
968 | 968 |
969 c.Sblock('%s%s %sParse%s(const std::string& enum_string) {' % | 969 c.Sblock('%s%s %sParse%s(const std::string& enum_string) {' % |
970 (maybe_namespace, classname, maybe_namespace, classname)) | 970 (maybe_namespace, classname, maybe_namespace, classname)) |
971 for _, enum_value in enumerate( | 971 for _, enum_value in enumerate( |
972 self._type_helper.FollowRef(type_).enum_values): | 972 self._type_helper.FollowRef(type_).enum_values): |
973 # This is broken up into all ifs with no else ifs because we get | 973 # This is broken up into all ifs with no else ifs because we get |
974 # "fatal error C1061: compiler limit : blocks nested too deeply" | 974 # "fatal error C1061: compiler limit : blocks nested too deeply" |
975 # on Windows. | 975 # on Windows. |
976 (c.Append('if (enum_string == "%s")' % enum_value.name) | 976 name = enum_value.name |
| 977 if 'camel_case_enum_to_string' in self._namespace.compiler_options: |
| 978 name = enum_value.CamelName() |
| 979 (c.Append('if (enum_string == "%s")' % name) |
977 .Append(' return %s;' % | 980 .Append(' return %s;' % |
978 self._type_helper.GetEnumValue(type_, enum_value))) | 981 self._type_helper.GetEnumValue(type_, enum_value))) |
979 (c.Append('return %s;' % self._type_helper.GetEnumNoneValue(type_)) | 982 (c.Append('return %s;' % self._type_helper.GetEnumNoneValue(type_)) |
980 .Eblock('}') | 983 .Eblock('}') |
981 ) | 984 ) |
982 return c | 985 return c |
983 | 986 |
984 def _GenerateCreateCallbackArguments(self, | 987 def _GenerateCreateCallbackArguments(self, |
985 function_scope, | 988 function_scope, |
986 callback): | 989 callback): |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 if self._generate_error_messages: | 1070 if self._generate_error_messages: |
1068 params = list(params) + ['base::string16* error'] | 1071 params = list(params) + ['base::string16* error'] |
1069 return ', '.join(str(p) for p in params) | 1072 return ', '.join(str(p) for p in params) |
1070 | 1073 |
1071 def _GenerateArgs(self, args): | 1074 def _GenerateArgs(self, args): |
1072 """Builds the argument list for a function, given an array of arguments. | 1075 """Builds the argument list for a function, given an array of arguments. |
1073 """ | 1076 """ |
1074 if self._generate_error_messages: | 1077 if self._generate_error_messages: |
1075 args = list(args) + ['error'] | 1078 args = list(args) + ['error'] |
1076 return ', '.join(str(a) for a in args) | 1079 return ', '.join(str(a) for a in args) |
OLD | NEW |