OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 'No definition found in %s' % idl_filename) | 68 'No definition found in %s' % idl_filename) |
69 return | 69 return |
70 target = targets[0] | 70 target = targets[0] |
71 if not target.is_partial and target.name != idl_file_basename: | 71 if not target.is_partial and target.name != idl_file_basename: |
72 raise Exception( | 72 raise Exception( |
73 'Definition name "{0}" disagrees with IDL file basename "{1}".' | 73 'Definition name "{0}" disagrees with IDL file basename "{1}".' |
74 .format(target.name, idl_file_basename)) | 74 .format(target.name, idl_file_basename)) |
75 | 75 |
76 | 76 |
77 class IdlReader(object): | 77 class IdlReader(object): |
78 def __init__(self, interfaces_info=None, outputdir=''): | 78 def __init__(self, interfaces_info=None, outputdir='', multi_interface=False
): |
| 79 self.multi_interface = multi_interface |
79 self.extended_attribute_validator = IDLExtendedAttributeValidator() | 80 self.extended_attribute_validator = IDLExtendedAttributeValidator() |
80 self.interfaces_info = interfaces_info | 81 self.interfaces_info = interfaces_info |
81 | 82 |
82 if interfaces_info: | 83 if interfaces_info: |
83 self.interface_dependency_resolver = InterfaceDependencyResolver(int
erfaces_info, self) | 84 self.interface_dependency_resolver = InterfaceDependencyResolver(int
erfaces_info, self) |
84 else: | 85 else: |
85 self.interface_dependency_resolver = None | 86 self.interface_dependency_resolver = None |
86 | 87 |
87 self.parser = BlinkIDLParser(outputdir=outputdir) | 88 self.parser = BlinkIDLParser(outputdir=outputdir) |
88 | 89 |
(...skipping 17 matching lines...) Expand all Loading... |
106 | 107 |
107 The IdlDefinitions object is guaranteed to contain a single | 108 The IdlDefinitions object is guaranteed to contain a single |
108 IdlInterface; it may also contain other definitions, such as | 109 IdlInterface; it may also contain other definitions, such as |
109 callback functions and enumerations.""" | 110 callback functions and enumerations.""" |
110 ast = blink_idl_parser.parse_file(self.parser, idl_filename) | 111 ast = blink_idl_parser.parse_file(self.parser, idl_filename) |
111 if not ast: | 112 if not ast: |
112 raise Exception('Failed to parse %s' % idl_filename) | 113 raise Exception('Failed to parse %s' % idl_filename) |
113 idl_file_basename, _ = os.path.splitext(os.path.basename(idl_filename)) | 114 idl_file_basename, _ = os.path.splitext(os.path.basename(idl_filename)) |
114 definitions = IdlDefinitions(idl_file_basename, ast) | 115 definitions = IdlDefinitions(idl_file_basename, ast) |
115 | 116 |
116 validate_blink_idl_definitions( | 117 if not self.multi_interface: |
117 idl_filename, idl_file_basename, definitions) | 118 validate_blink_idl_definitions(idl_filename, idl_file_basename, defi
nitions) |
| 119 else: |
| 120 if len(definitions.interfaces) > 1: |
| 121 print '----- Supplemental interfaces %s' % len(definitions.inter
faces) |
118 | 122 |
119 # Validate extended attributes | 123 # Validate extended attributes |
120 if not self.extended_attribute_validator: | 124 if not self.extended_attribute_validator: |
121 return definitions | 125 return definitions |
122 | 126 |
123 try: | 127 try: |
124 self.extended_attribute_validator.validate_extended_attributes(defin
itions) | 128 self.extended_attribute_validator.validate_extended_attributes(defin
itions) |
125 except IDLInvalidExtendedAttributeError as error: | 129 except IDLInvalidExtendedAttributeError as error: |
126 raise IDLInvalidExtendedAttributeError(""" | 130 raise IDLInvalidExtendedAttributeError(""" |
127 IDL ATTRIBUTE ERROR in file: | 131 IDL ATTRIBUTE ERROR in file: |
128 %s: | 132 %s: |
129 %s | 133 %s |
130 If you want to add a new IDL extended attribute, please add it to: | 134 If you want to add a new IDL extended attribute, please add it to: |
131 %s | 135 %s |
132 and add an explanation to the Blink IDL documentation at: | 136 and add an explanation to the Blink IDL documentation at: |
133 http://www.chromium.org/blink/webidl/blink-idl-extended-attributes | 137 http://www.chromium.org/blink/webidl/blink-idl-extended-attributes |
134 """ % (idl_filename, str(error), EXTENDED_ATTRIBUTES_RELATIVE_PATH)) | 138 """ % (idl_filename, str(error), EXTENDED_ATTRIBUTES_RELATIVE_PATH)) |
135 | 139 |
136 return definitions | 140 return definitions |
OLD | NEW |