OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 '''python %prog [options] platform chromium_os_flag template | 6 '''python %prog [options] platform chromium_os_flag template |
7 | 7 |
8 platform specifies which platform source is being generated for | 8 platform specifies which platform source is being generated for |
9 and can be one of (win, mac, linux) | 9 and can be one of (win, mac, linux) |
10 chromium_os_flag should be 1 if this is a Chromium OS build | 10 chromium_os_flag should be 1 if this is a Chromium OS build |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 return self.GetSimpleType(schema['type']) | 413 return self.GetSimpleType(schema['type']) |
414 elif 'enum' in schema: | 414 elif 'enum' in schema: |
415 return self.GetEnumType(schema, name) | 415 return self.GetEnumType(schema, name) |
416 elif 'pattern' in schema: | 416 elif 'pattern' in schema: |
417 return self.GetPatternType(schema, name) | 417 return self.GetPatternType(schema, name) |
418 else: | 418 else: |
419 return self.GetRangedType(schema, name) | 419 return self.GetRangedType(schema, name) |
420 | 420 |
421 if schema['type'] == 'array': | 421 if schema['type'] == 'array': |
422 # Special case for lists of strings, which is a common policy type. | 422 # Special case for lists of strings, which is a common policy type. |
423 if schema['items']['type'] == 'string': | 423 # The 'type' may be missing if the schema has a '$ref' attribute. |
| 424 if schema['items'].get('type', '') == 'string': |
424 return self.GetStringList() | 425 return self.GetStringList() |
425 return self.AppendSchema('TYPE_LIST', | 426 return self.AppendSchema('TYPE_LIST', |
426 self.GenerateAndCollectID(schema['items'], 'items of ' + name)) | 427 self.GenerateAndCollectID(schema['items'], 'items of ' + name)) |
427 elif schema['type'] == 'object': | 428 elif schema['type'] == 'object': |
428 # Reserve an index first, so that dictionaries come before their | 429 # Reserve an index first, so that dictionaries come before their |
429 # properties. This makes sure that the root node is the first in the | 430 # properties. This makes sure that the root node is the first in the |
430 # SchemaNodes array. | 431 # SchemaNodes array. |
431 index = self.AppendSchema('TYPE_DICTIONARY', -1) | 432 index = self.AppendSchema('TYPE_DICTIONARY', -1) |
432 | 433 |
433 if 'additionalProperties' in schema: | 434 if 'additionalProperties' in schema: |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 def _WriteCloudPolicyDecoder(policies, os, f): | 918 def _WriteCloudPolicyDecoder(policies, os, f): |
918 f.write(CPP_HEAD) | 919 f.write(CPP_HEAD) |
919 for policy in policies: | 920 for policy in policies: |
920 if policy.is_supported and not policy.is_device_only: | 921 if policy.is_supported and not policy.is_device_only: |
921 _WritePolicyCode(f, policy) | 922 _WritePolicyCode(f, policy) |
922 f.write(CPP_FOOT) | 923 f.write(CPP_FOOT) |
923 | 924 |
924 | 925 |
925 if __name__ == '__main__': | 926 if __name__ == '__main__': |
926 sys.exit(main()) | 927 sys.exit(main()) |
OLD | NEW |