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, Type | 6 from model import PropertyType, Type |
7 import cpp_util | 7 import cpp_util |
8 import model | 8 import model |
9 import schema_util | 9 import schema_util |
10 import sys | 10 import sys |
(...skipping 24 matching lines...) Expand all Loading... |
35 def Generate(self): | 35 def Generate(self): |
36 """Generates a Code object with the .cc for a single namespace. | 36 """Generates a Code object with the .cc for a single namespace. |
37 """ | 37 """ |
38 c = Code() | 38 c = Code() |
39 (c.Append(cpp_util.CHROMIUM_LICENSE) | 39 (c.Append(cpp_util.CHROMIUM_LICENSE) |
40 .Append() | 40 .Append() |
41 .Append(cpp_util.GENERATED_FILE_MESSAGE % self._namespace.source_file) | 41 .Append(cpp_util.GENERATED_FILE_MESSAGE % self._namespace.source_file) |
42 .Append() | 42 .Append() |
43 .Append(self._util_cc_helper.GetIncludePath()) | 43 .Append(self._util_cc_helper.GetIncludePath()) |
44 .Append('#include "base/logging.h"') | 44 .Append('#include "base/logging.h"') |
45 .Append('#include "base/string_number_conversions.h"') | 45 .Append('#include "base/strings/string_number_conversions.h"') |
46 .Append('#include "%s/%s.h"' % | 46 .Append('#include "%s/%s.h"' % |
47 (self._namespace.source_file_dir, self._namespace.unix_name)) | 47 (self._namespace.source_file_dir, self._namespace.unix_name)) |
48 .Cblock(self._type_helper.GenerateIncludes(include_soft=True)) | 48 .Cblock(self._type_helper.GenerateIncludes(include_soft=True)) |
49 .Append() | 49 .Append() |
50 .Concat(cpp_util.OpenNamespace(self._cpp_namespace)) | 50 .Concat(cpp_util.OpenNamespace(self._cpp_namespace)) |
51 .Cblock(self._type_helper.GetNamespaceStart()) | 51 .Cblock(self._type_helper.GetNamespaceStart()) |
52 ) | 52 ) |
53 if self._namespace.properties: | 53 if self._namespace.properties: |
54 (c.Append('//') | 54 (c.Append('//') |
55 .Append('// Properties') | 55 .Append('// Properties') |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 """ | 834 """ |
835 c = Code() | 835 c = Code() |
836 underlying_type = self._type_helper.FollowRef(prop.type_) | 836 underlying_type = self._type_helper.FollowRef(prop.type_) |
837 if (underlying_type.property_type == PropertyType.ENUM and | 837 if (underlying_type.property_type == PropertyType.ENUM and |
838 prop.optional): | 838 prop.optional): |
839 c.Append('%s->%s = %s;' % ( | 839 c.Append('%s->%s = %s;' % ( |
840 dst, | 840 dst, |
841 prop.unix_name, | 841 prop.unix_name, |
842 self._type_helper.GetEnumNoneValue(prop.type_))) | 842 self._type_helper.GetEnumNoneValue(prop.type_))) |
843 return c | 843 return c |
OLD | NEW |