Chromium Code Reviews| 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 | 6 from model import PropertyType |
| 7 import any_helper | 7 import any_helper |
| 8 import cpp_util | 8 import cpp_util |
| 9 import model | 9 import model |
| 10 import sys | 10 import sys |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 # TODO(calamity): Events | 92 # TODO(calamity): Events |
| 93 return c | 93 return c |
| 94 | 94 |
| 95 def _GenerateType(self, cpp_namespace, type_): | 95 def _GenerateType(self, cpp_namespace, type_): |
| 96 """Generates the function definitions for a type. | 96 """Generates the function definitions for a type. |
| 97 """ | 97 """ |
| 98 classname = cpp_util.Classname(type_.name) | 98 classname = cpp_util.Classname(type_.name) |
| 99 c = Code() | 99 c = Code() |
| 100 | 100 |
| 101 if type_.functions: | 101 if type_.functions: |
| 102 # Types with functions are not instantiable in C++ because they are | |
| 103 # handled in pure Javascript and hence have no properties or | |
| 104 # additionalProperties. | |
| 105 if type_.properties: | |
| 106 raise NotImplementedError('\n'.join(model.GetModelHierarchy(type_)) + | |
| 107 '\nCannot generate both functions and properties on a type') | |
|
battre
2012/05/09 16:28:08
The files generated after deleting this exception
not at google - send to devlin
2012/05/10 09:01:25
I don't quite understand what you mean, can you gi
battre
2012/05/10 16:40:29
Look at the events.json of this CL. The Event obje
| |
| 108 for function in type_.functions.values(): | 102 for function in type_.functions.values(): |
| 109 (c.Concat( | 103 (c.Concat( |
| 110 self._GenerateFunction( | 104 self._GenerateFunction( |
| 111 cpp_namespace + '::' + cpp_util.Classname(function.name), | 105 cpp_namespace + '::' + cpp_util.Classname(function.name), |
| 112 function)) | 106 function)) |
| 113 .Append() | 107 .Append() |
| 114 ) | 108 ) |
| 115 elif type_.type_ == PropertyType.OBJECT: | 109 elif type_.type_ == PropertyType.OBJECT: |
| 116 (c.Concat(self._GeneratePropertyFunctions( | 110 (c.Concat(self._GeneratePropertyFunctions( |
| 117 cpp_namespace, type_.properties.values())) | 111 cpp_namespace, type_.properties.values())) |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 659 """ | 653 """ |
| 660 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == | 654 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == |
| 661 PropertyType.ARRAY) | 655 PropertyType.ARRAY) |
| 662 | 656 |
| 663 def _IsFundamentalOrFundamentalRef(self, prop): | 657 def _IsFundamentalOrFundamentalRef(self, prop): |
| 664 """Determines if this property is a Fundamental type or is a ref to a | 658 """Determines if this property is a Fundamental type or is a ref to a |
| 665 Fundamental type. | 659 Fundamental type. |
| 666 """ | 660 """ |
| 667 return (self._cpp_type_generator.GetReferencedProperty(prop).type_. | 661 return (self._cpp_type_generator.GetReferencedProperty(prop).type_. |
| 668 is_fundamental) | 662 is_fundamental) |
| OLD | NEW |