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 21 matching lines...) Expand all Loading... |
32 http://www.chromium.org/developers/design-documents/idl-compiler#TOC-Front-end | 32 http://www.chromium.org/developers/design-documents/idl-compiler#TOC-Front-end |
33 """ | 33 """ |
34 | 34 |
35 import os | 35 import os |
36 | 36 |
37 import blink_idl_parser | 37 import blink_idl_parser |
38 from blink_idl_parser import BlinkIDLParser | 38 from blink_idl_parser import BlinkIDLParser |
39 from idl_definitions import IdlDefinitions | 39 from idl_definitions import IdlDefinitions |
40 from idl_validator import EXTENDED_ATTRIBUTES_RELATIVE_PATH, IDLInvalidExtendedA
ttributeError, IDLExtendedAttributeValidator | 40 from idl_validator import EXTENDED_ATTRIBUTES_RELATIVE_PATH, IDLInvalidExtendedA
ttributeError, IDLExtendedAttributeValidator |
41 from interface_dependency_resolver import InterfaceDependencyResolver | 41 from interface_dependency_resolver import InterfaceDependencyResolver |
| 42 from utilities import idl_filename_to_component |
42 | 43 |
43 | 44 |
44 class IdlReader(object): | 45 class IdlReader(object): |
45 def __init__(self, interfaces_info=None, outputdir='', multi_interface=False
): | 46 def __init__(self, interfaces_info=None, outputdir='', multi_interface=False
): |
46 self.multi_interface = multi_interface | 47 self.multi_interface = multi_interface |
47 self.extended_attribute_validator = IDLExtendedAttributeValidator() | 48 self.extended_attribute_validator = IDLExtendedAttributeValidator() |
| 49 self.interfaces_info = interfaces_info |
48 | 50 |
49 if interfaces_info: | 51 if interfaces_info: |
50 self.interface_dependency_resolver = InterfaceDependencyResolver(int
erfaces_info, self) | 52 self.interface_dependency_resolver = InterfaceDependencyResolver(int
erfaces_info, self) |
51 else: | 53 else: |
52 self.interface_dependency_resolver = None | 54 self.interface_dependency_resolver = None |
53 | 55 |
54 self.parser = BlinkIDLParser(outputdir=outputdir) | 56 self.parser = BlinkIDLParser(outputdir=outputdir) |
55 | 57 |
56 def read_idl_definitions(self, idl_filename): | 58 def read_idl_definitions(self, idl_filename): |
57 """Returns an IdlDefinitions object for an IDL file, including all depen
dencies.""" | 59 """Returns a dictionary whose key is component and value is an IdlDefini
tions object for an IDL file, including all dependencies.""" |
58 definitions = self.read_idl_file(idl_filename) | 60 definitions = self.read_idl_file(idl_filename) |
| 61 component = idl_filename_to_component(idl_filename) |
| 62 |
59 if not self.interface_dependency_resolver: | 63 if not self.interface_dependency_resolver: |
60 return definitions | 64 return {component: definitions} |
61 self.interface_dependency_resolver.resolve_dependencies(definitions) | 65 |
62 return definitions | 66 # This definitions should have a dictionary. No need to resolve any |
| 67 # dependencies. |
| 68 if not definitions.interfaces: |
| 69 return {component: definitions} |
| 70 |
| 71 return self.interface_dependency_resolver.resolve_dependencies(definitio
ns, component) |
63 | 72 |
64 def read_idl_file(self, idl_filename): | 73 def read_idl_file(self, idl_filename): |
65 """Returns an IdlDefinitions object for an IDL file, without any depende
ncies. | 74 """Returns an IdlDefinitions object for an IDL file, without any depende
ncies. |
66 | 75 |
67 The IdlDefinitions object is guaranteed to contain a single | 76 The IdlDefinitions object is guaranteed to contain a single |
68 IdlInterface; it may also contain other definitions, such as | 77 IdlInterface; it may also contain other definitions, such as |
69 callback functions and enumerations.""" | 78 callback functions and enumerations.""" |
70 ast = blink_idl_parser.parse_file(self.parser, idl_filename) | 79 ast = blink_idl_parser.parse_file(self.parser, idl_filename) |
71 if not ast: | 80 if not ast: |
72 raise Exception('Failed to parse %s' % idl_filename) | 81 raise Exception('Failed to parse %s' % idl_filename) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 IDL ATTRIBUTE ERROR in file: | 116 IDL ATTRIBUTE ERROR in file: |
108 %s: | 117 %s: |
109 %s | 118 %s |
110 If you want to add a new IDL extended attribute, please add it to: | 119 If you want to add a new IDL extended attribute, please add it to: |
111 %s | 120 %s |
112 and add an explanation to the Blink IDL documentation at: | 121 and add an explanation to the Blink IDL documentation at: |
113 http://www.chromium.org/blink/webidl/blink-idl-extended-attributes | 122 http://www.chromium.org/blink/webidl/blink-idl-extended-attributes |
114 """ % (idl_filename, str(error), EXTENDED_ATTRIBUTES_RELATIVE_PATH)) | 123 """ % (idl_filename, str(error), EXTENDED_ATTRIBUTES_RELATIVE_PATH)) |
115 | 124 |
116 return definitions | 125 return definitions |
OLD | NEW |