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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 return entry['interfaceName'] | 72 return entry['interfaceName'] |
73 return os.path.basename(entry['name']) | 73 return os.path.basename(entry['name']) |
74 | 74 |
75 class Writer(in_generator.Writer): | 75 class Writer(in_generator.Writer): |
76 def __init__(self, in_file_path, enabled_conditions): | 76 def __init__(self, in_file_path, enabled_conditions): |
77 super(Writer, self).__init__(in_file_path, enabled_conditions) | 77 super(Writer, self).__init__(in_file_path, enabled_conditions) |
78 self.class_name = self.in_file.parameters['namespace'].strip('"') | 78 self.class_name = self.in_file.parameters['namespace'].strip('"') |
79 self._entries_by_conditional = {} | 79 self._entries_by_conditional = {} |
80 self._unconditional_entries = [] | 80 self._unconditional_entries = [] |
81 self._sort_entries_by_conditional() | 81 self._sort_entries_by_conditional() |
| 82 self._outputs = {(self.class_name + "Headers.h"): self.generate_headers_
header, |
| 83 (self.class_name + "Interfaces.h"): self.generate_inter
faces_header, |
| 84 } |
82 | 85 |
83 def _sort_entries_by_conditional(self): | 86 def _sort_entries_by_conditional(self): |
84 unconditional_names = set() | 87 unconditional_names = set() |
85 for entry in self.in_file.name_dictionaries: | 88 for entry in self.in_file.name_dictionaries: |
86 conditional = entry['conditional'] | 89 conditional = entry['conditional'] |
87 if not conditional: | 90 if not conditional: |
88 name = _name_for_entry(entry) | 91 name = _name_for_entry(entry) |
89 if name in unconditional_names: | 92 if name in unconditional_names: |
90 continue | 93 continue |
91 unconditional_names.add(name) | 94 unconditional_names.add(name) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 153 |
151 def generate_interfaces_header(self): | 154 def generate_interfaces_header(self): |
152 return INTERFACES_HEADER_TEMPLATE % { | 155 return INTERFACES_HEADER_TEMPLATE % { |
153 'license': license.license_for_generated_cpp(), | 156 'license': license.license_for_generated_cpp(), |
154 'class_name': self.class_name, | 157 'class_name': self.class_name, |
155 'macro_style_name': _to_macro_style(self.class_name), | 158 'macro_style_name': _to_macro_style(self.class_name), |
156 'declare_conditional_macros': self._declare_conditional_macros(), | 159 'declare_conditional_macros': self._declare_conditional_macros(), |
157 'unconditional_macros': '\n'.join(sorted(set(map(self._unconditional
_macro, self._unconditional_entries)))), | 160 'unconditional_macros': '\n'.join(sorted(set(map(self._unconditional
_macro, self._unconditional_entries)))), |
158 'conditional_macros': '\n'.join(map(self._conditional_macros, self._
entries_by_conditional.keys())), | 161 'conditional_macros': '\n'.join(map(self._conditional_macros, self._
entries_by_conditional.keys())), |
159 } | 162 } |
OLD | NEW |