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 import copy | 5 import copy |
6 import os.path | 6 import os.path |
7 import re | 7 import re |
8 | 8 |
9 class ParseException(Exception): | 9 class ParseException(Exception): |
10 """Thrown when data in the model is invalid. | 10 """Thrown when data in the model is invalid. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 parameters | 69 parameters |
70 - |type_| the PropertyType of this Type | 70 - |type_| the PropertyType of this Type |
71 - |item_type| if this is an array, the type of items in the array | 71 - |item_type| if this is an array, the type of items in the array |
72 """ | 72 """ |
73 def __init__(self, parent, name, json): | 73 def __init__(self, parent, name, json): |
74 if json.get('type') == 'array': | 74 if json.get('type') == 'array': |
75 self.type_ = PropertyType.ARRAY | 75 self.type_ = PropertyType.ARRAY |
76 self.item_type = Property(self, name + "Element", json['items'], | 76 self.item_type = Property(self, name + "Element", json['items'], |
77 from_json=True, | 77 from_json=True, |
78 from_client=True) | 78 from_client=True) |
| 79 elif json.get('type') == 'string': |
| 80 self.type_ = PropertyType.STRING |
79 else: | 81 else: |
80 if not ( | 82 if not ( |
81 'properties' in json or | 83 'properties' in json or |
82 'additionalProperties' in json or | 84 'additionalProperties' in json or |
83 'functions' in json): | 85 'functions' in json): |
84 raise ParseException(self, name + " has no properties or functions") | 86 raise ParseException(self, name + " has no properties or functions") |
85 self.type_ = PropertyType.OBJECT | 87 self.type_ = PropertyType.OBJECT |
86 self.name = name | 88 self.name = name |
87 self.description = json.get('description') | 89 self.description = json.get('description') |
88 self.from_json = True | 90 self.from_json = True |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 # handled in pure Javascript on the render process (and .: never reach | 360 # handled in pure Javascript on the render process (and .: never reach |
359 # C++ let alone the browser). | 361 # C++ let alone the browser). |
360 if property_json.get('type') == 'function': | 362 if property_json.get('type') == 'function': |
361 continue | 363 continue |
362 model.properties[name] = Property( | 364 model.properties[name] = Property( |
363 model, | 365 model, |
364 name, | 366 name, |
365 property_json, | 367 property_json, |
366 from_json=from_json, | 368 from_json=from_json, |
367 from_client=from_client) | 369 from_client=from_client) |
OLD | NEW |