OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (C) 2013 Google Inc. All rights reserved. | 2 # Copyright (C) 2013 Google Inc. All rights reserved. |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 'export': '', | 52 'export': '', |
53 } | 53 } |
54 filters = { | 54 filters = { |
55 'cpp_name': name_utilities.cpp_name, | 55 'cpp_name': name_utilities.cpp_name, |
56 'hash': hasher.hash, | 56 'hash': hasher.hash, |
57 'script_name': name_utilities.script_name, | 57 'script_name': name_utilities.script_name, |
58 'symbol': _symbol, | 58 'symbol': _symbol, |
59 'to_macro_style': name_utilities.to_macro_style, | 59 'to_macro_style': name_utilities.to_macro_style, |
60 } | 60 } |
61 | 61 |
62 def __init__(self, in_file_path, enabled_conditions): | 62 def __init__(self, in_file_path): |
63 super(MakeNamesWriter, self).__init__(in_file_path, enabled_conditions) | 63 super(MakeNamesWriter, self).__init__(in_file_path) |
64 | 64 |
65 namespace = self.in_file.parameters['namespace'].strip('"') | 65 namespace = self.in_file.parameters['namespace'].strip('"') |
66 export = self.in_file.parameters['export'].strip('"') | 66 export = self.in_file.parameters['export'].strip('"') |
67 | 67 |
68 assert namespace, 'A namespace is required.' | 68 assert namespace, 'A namespace is required.' |
69 | 69 |
70 self._outputs = { | 70 self._outputs = { |
71 (namespace + 'Names.h'): self.generate_header, | 71 (namespace + 'Names.h'): self.generate_header, |
72 (namespace + 'Names.cpp'): self.generate_implementation, | 72 (namespace + 'Names.cpp'): self.generate_implementation, |
73 } | 73 } |
74 self._template_context = { | 74 self._template_context = { |
75 'namespace': namespace, | 75 'namespace': namespace, |
76 'export': export, | 76 'export': export, |
77 'entries': self.in_file.name_dictionaries, | 77 'entries': self.in_file.name_dictionaries, |
78 } | 78 } |
79 | 79 |
80 @template_expander.use_jinja("MakeNames.h.tmpl", filters=filters) | 80 @template_expander.use_jinja("MakeNames.h.tmpl", filters=filters) |
81 def generate_header(self): | 81 def generate_header(self): |
82 return self._template_context | 82 return self._template_context |
83 | 83 |
84 @template_expander.use_jinja("MakeNames.cpp.tmpl", filters=filters) | 84 @template_expander.use_jinja("MakeNames.cpp.tmpl", filters=filters) |
85 def generate_implementation(self): | 85 def generate_implementation(self): |
86 return self._template_context | 86 return self._template_context |
87 | 87 |
88 | 88 |
89 if __name__ == "__main__": | 89 if __name__ == "__main__": |
90 in_generator.Maker(MakeNamesWriter).main(sys.argv) | 90 in_generator.Maker(MakeNamesWriter).main(sys.argv) |
OLD | NEW |