| 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 | |
| 10 | 9 |
| 11 CHROMIUM_LICENSE = ( | 10 CHROMIUM_LICENSE = ( |
| 12 """// Copyright (c) %d The Chromium Authors. All rights reserved. | 11 """// Copyright (c) %d The Chromium Authors. All rights reserved. |
| 13 // Use of this source code is governed by a BSD-style license that can be | 12 // Use of this source code is governed by a BSD-style license that can be |
| 14 // found in the LICENSE file.""" % datetime.now().year | 13 // found in the LICENSE file.""" % datetime.now().year |
| 15 ) | 14 ) |
| 16 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN | 15 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN |
| 17 // %s | 16 // %s |
| 18 // DO NOT EDIT. | 17 // DO NOT EDIT. |
| 19 """ | 18 """ |
| 20 GENERATED_BUNDLE_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITIONS IN | |
| 21 // %s | |
| 22 // DO NOT EDIT. | |
| 23 """ | |
| 24 | 19 |
| 25 def Classname(s): | 20 def Classname(s): |
| 26 """Translates a namespace name or function name into something more | 21 """Translates a namespace name or function name into something more |
| 27 suited to C++. | 22 suited to C++. |
| 28 | 23 |
| 29 eg experimental.downloads -> Experimental_Downloads | 24 eg experimental.downloads -> Experimental_Downloads |
| 30 updateAll -> UpdateAll. | 25 updateAll -> UpdateAll. |
| 31 """ | 26 """ |
| 32 return '_'.join([x[0].upper() + x[1:] for x in s.split('.')]) | 27 return '_'.join([x[0].upper() + x[1:] for x in s.split('.')]) |
| 33 | 28 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 """ | 60 """ |
| 66 if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY, | 61 if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY, |
| 67 PropertyType.STRING): | 62 PropertyType.STRING): |
| 68 arg = '%(type)s& %(name)s' | 63 arg = '%(type)s& %(name)s' |
| 69 else: | 64 else: |
| 70 arg = '%(type)s %(name)s' | 65 arg = '%(type)s %(name)s' |
| 71 return arg % { | 66 return arg % { |
| 72 'type': type_, | 67 'type': type_, |
| 73 'name': param.unix_name, | 68 'name': param.unix_name, |
| 74 } | 69 } |
| 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 |