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 code import Code |
9 from datetime import datetime | 9 from datetime import datetime |
10 from model import PropertyType | 10 from model import PropertyType |
(...skipping 23 matching lines...) Expand all Loading... |
34 suited to C++. | 34 suited to C++. |
35 | 35 |
36 eg experimental.downloads -> Experimental_Downloads | 36 eg experimental.downloads -> Experimental_Downloads |
37 updateAll -> UpdateAll. | 37 updateAll -> UpdateAll. |
38 """ | 38 """ |
39 if s == '': | 39 if s == '': |
40 return 'EMPTY_STRING' | 40 return 'EMPTY_STRING' |
41 return '_'.join([x[0].upper() + x[1:] for x in re.split('\W', s)]) | 41 return '_'.join([x[0].upper() + x[1:] for x in re.split('\W', s)]) |
42 | 42 |
43 | 43 |
44 def GetAsFundamentalValue(type_, src, dst): | 44 def GetAsValue(type_, src, dst): |
45 """Returns the C++ code for retrieving a fundamental type from a | 45 """Returns the C++ code for retrieving a fundamental type from a |
46 Value into a variable. | 46 Value into a variable. |
47 | 47 |
48 src: Value* | 48 src: Value* |
49 dst: Property* | 49 dst: Property* |
50 """ | 50 """ |
51 return { | 51 return { |
52 PropertyType.BOOLEAN: '%s->GetAsBoolean(%s)', | 52 PropertyType.BOOLEAN: '%s->GetAsBoolean(%s)', |
53 PropertyType.DOUBLE: '%s->GetAsDouble(%s)', | 53 PropertyType.DOUBLE: '%s->GetAsDouble(%s)', |
54 PropertyType.INTEGER: '%s->GetAsInteger(%s)', | 54 PropertyType.INTEGER: '%s->GetAsInteger(%s)', |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 has been passed as a flag to compiler.py from GYP/GN. | 152 has been passed as a flag to compiler.py from GYP/GN. |
153 ''' | 153 ''' |
154 # For some reason Windows builds escape the % characters, so unescape them. | 154 # For some reason Windows builds escape the % characters, so unescape them. |
155 # This means that %% can never appear legitimately within a pattern, but | 155 # This means that %% can never appear legitimately within a pattern, but |
156 # that's ok. It should never happen. | 156 # that's ok. It should never happen. |
157 cpp_namespace = pattern.replace('%%', '%') % { 'namespace': namespace } | 157 cpp_namespace = pattern.replace('%%', '%') % { 'namespace': namespace } |
158 assert '%' not in cpp_namespace, \ | 158 assert '%' not in cpp_namespace, \ |
159 ('Did not manage to fully substitute namespace "%s" into pattern "%s"' | 159 ('Did not manage to fully substitute namespace "%s" into pattern "%s"' |
160 % (namespace, pattern)) | 160 % (namespace, pattern)) |
161 return cpp_namespace | 161 return cpp_namespace |
OLD | NEW |