| 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 """Utilies and constants specific to Chromium C++ code. | 5 """Utilies and constants specific to Chromium C++ code. |
| 6 """ | 6 """ |
| 7 | 7 |
| 8 from code import Code |
| 8 from datetime import datetime | 9 from datetime import datetime |
| 9 from model import Property, PropertyType, Type | 10 from model import Property, PropertyType, Type |
| 10 import os | 11 import os |
| 11 | 12 |
| 12 CHROMIUM_LICENSE = ( | 13 CHROMIUM_LICENSE = ( |
| 13 """// Copyright (c) %d The Chromium Authors. All rights reserved. | 14 """// Copyright (c) %d The Chromium Authors. All rights reserved. |
| 14 // Use of this source code is governed by a BSD-style license that can be | 15 // Use of this source code is governed by a BSD-style license that can be |
| 15 // found in the LICENSE file.""" % datetime.now().year | 16 // found in the LICENSE file.""" % datetime.now().year |
| 16 ) | 17 ) |
| 17 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN | 18 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 e.g chrome/extensions/gen, file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__. | 85 e.g chrome/extensions/gen, file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__. |
| 85 """ | 86 """ |
| 86 return (('%s_%s_H__' % (path, filename)) | 87 return (('%s_%s_H__' % (path, filename)) |
| 87 .upper().replace(os.sep, '_').replace('/', '_')) | 88 .upper().replace(os.sep, '_').replace('/', '_')) |
| 88 | 89 |
| 89 def PadForGenerics(var): | 90 def PadForGenerics(var): |
| 90 """Appends a space to |var| if it ends with a >, so that it can be compiled | 91 """Appends a space to |var| if it ends with a >, so that it can be compiled |
| 91 within generic types. | 92 within generic types. |
| 92 """ | 93 """ |
| 93 return ('%s ' % var) if var.endswith('>') else var | 94 return ('%s ' % var) if var.endswith('>') else var |
| 95 |
| 96 def OpenNamespace(namespace): |
| 97 """Get opening root namespace declarations. |
| 98 """ |
| 99 c = Code() |
| 100 for component in namespace.split('::'): |
| 101 c.Append('namespace %s {' % component) |
| 102 return c |
| 103 |
| 104 def CloseNamespace(namespace): |
| 105 """Get closing root namespace declarations. |
| 106 """ |
| 107 c = Code() |
| 108 for component in reversed(namespace.split('::')): |
| 109 c.Append('} // namespace %s' % component) |
| 110 return c |
| OLD | NEW |