| 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 | 10 |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 classname = cpp_util.Classname(schema_util.StripNamespace(type_.name)) | 883 classname = cpp_util.Classname(schema_util.StripNamespace(type_.name)) |
| 884 | 884 |
| 885 if cpp_namespace is not None: | 885 if cpp_namespace is not None: |
| 886 c.Append('// static') | 886 c.Append('// static') |
| 887 maybe_namespace = '' if cpp_namespace is None else '%s::' % cpp_namespace | 887 maybe_namespace = '' if cpp_namespace is None else '%s::' % cpp_namespace |
| 888 | 888 |
| 889 c.Sblock('std::string %sToString(%s enum_param) {' % | 889 c.Sblock('std::string %sToString(%s enum_param) {' % |
| 890 (maybe_namespace, classname)) | 890 (maybe_namespace, classname)) |
| 891 c.Sblock('switch (enum_param) {') | 891 c.Sblock('switch (enum_param) {') |
| 892 for enum_value in self._type_helper.FollowRef(type_).enum_values: | 892 for enum_value in self._type_helper.FollowRef(type_).enum_values: |
| 893 name = enum_value.name |
| 894 if 'camel_case_enum_to_string' in self._namespace.compiler_options: |
| 895 name = enum_value.CamelName() |
| 893 (c.Append('case %s: ' % self._type_helper.GetEnumValue(type_, enum_value)) | 896 (c.Append('case %s: ' % self._type_helper.GetEnumValue(type_, enum_value)) |
| 894 .Append(' return "%s";' % enum_value.name)) | 897 .Append(' return "%s";' % name)) |
| 895 (c.Append('case %s:' % self._type_helper.GetEnumNoneValue(type_)) | 898 (c.Append('case %s:' % self._type_helper.GetEnumNoneValue(type_)) |
| 896 .Append(' return "";') | 899 .Append(' return "";') |
| 897 .Eblock('}') | 900 .Eblock('}') |
| 898 .Append('NOTREACHED();') | 901 .Append('NOTREACHED();') |
| 899 .Append('return "";') | 902 .Append('return "";') |
| 900 .Eblock('}') | 903 .Eblock('}') |
| 901 ) | 904 ) |
| 902 return c | 905 return c |
| 903 | 906 |
| 904 def _GenerateEnumFromString(self, cpp_namespace, type_): | 907 def _GenerateEnumFromString(self, cpp_namespace, type_): |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 if self._generate_error_messages: | 1013 if self._generate_error_messages: |
| 1011 params = list(params) + ['base::string16* error'] | 1014 params = list(params) + ['base::string16* error'] |
| 1012 return ', '.join(str(p) for p in params) | 1015 return ', '.join(str(p) for p in params) |
| 1013 | 1016 |
| 1014 def _GenerateArgs(self, args): | 1017 def _GenerateArgs(self, args): |
| 1015 """Builds the argument list for a function, given an array of arguments. | 1018 """Builds the argument list for a function, given an array of arguments. |
| 1016 """ | 1019 """ |
| 1017 if self._generate_error_messages: | 1020 if self._generate_error_messages: |
| 1018 args = list(args) + ['error'] | 1021 args = list(args) + ['error'] |
| 1019 return ', '.join(str(a) for a in args) | 1022 return ', '.join(str(a) for a in args) |
| OLD | NEW |