| 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 """Utilies and constants specific to Chromium C++ code. | 4 """Utilies and constants specific to Chromium C++ code. |
| 5 """ | 5 """ |
| 6 | 6 |
| 7 from datetime import datetime | 7 from datetime import datetime |
| 8 from model import PropertyType | 8 from model import PropertyType |
| 9 import os |
| 9 | 10 |
| 10 CHROMIUM_LICENSE = ( | 11 CHROMIUM_LICENSE = ( |
| 11 """// Copyright (c) %d The Chromium Authors. All rights reserved. | 12 """// Copyright (c) %d The Chromium Authors. All rights reserved. |
| 12 // Use of this source code is governed by a BSD-style license that can be | 13 // Use of this source code is governed by a BSD-style license that can be |
| 13 // found in the LICENSE file.""" % datetime.now().year | 14 // found in the LICENSE file.""" % datetime.now().year |
| 14 ) | 15 ) |
| 15 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN | 16 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN |
| 16 // %s | 17 // %s |
| 17 // DO NOT EDIT. | 18 // DO NOT EDIT. |
| 18 """ | 19 """ |
| 20 GENERATED_BUNDLE_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITIONS IN |
| 21 // %s |
| 22 // DO NOT EDIT. |
| 23 """ |
| 19 | 24 |
| 20 def Classname(s): | 25 def Classname(s): |
| 21 """Translates a namespace name or function name into something more | 26 """Translates a namespace name or function name into something more |
| 22 suited to C++. | 27 suited to C++. |
| 23 | 28 |
| 24 eg experimental.downloads -> Experimental_Downloads | 29 eg experimental.downloads -> Experimental_Downloads |
| 25 updateAll -> UpdateAll. | 30 updateAll -> UpdateAll. |
| 26 """ | 31 """ |
| 27 return '_'.join([x[0].upper() + x[1:] for x in s.split('.')]) | 32 return '_'.join([x[0].upper() + x[1:] for x in s.split('.')]) |
| 28 | 33 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 """ | 65 """ |
| 61 if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY, | 66 if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY, |
| 62 PropertyType.STRING): | 67 PropertyType.STRING): |
| 63 arg = '%(type)s& %(name)s' | 68 arg = '%(type)s& %(name)s' |
| 64 else: | 69 else: |
| 65 arg = '%(type)s %(name)s' | 70 arg = '%(type)s %(name)s' |
| 66 return arg % { | 71 return arg % { |
| 67 'type': type_, | 72 'type': type_, |
| 68 'name': param.unix_name, | 73 'name': param.unix_name, |
| 69 } | 74 } |
| 75 |
| 76 def GenerateIfndefName(path, filename): |
| 77 """Formats a path and filename as a #define name. |
| 78 |
| 79 e.g chrome/extensions/gen, file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__. |
| 80 """ |
| 81 return (('%s_%s_H__' % (path, filename)) |
| 82 .upper().replace(os.sep, '_').replace('/', '_')) |
| OLD | NEW |