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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 or name.startswith('MouseEvent')) | 46 or name.startswith('MouseEvent')) |
47 | 47 |
48 class EventFactoryWriter(name_macros.Writer): | 48 class EventFactoryWriter(name_macros.Writer): |
49 defaults = { | 49 defaults = { |
50 'ImplementedAs': None, | 50 'ImplementedAs': None, |
51 'Conditional': None, | 51 'Conditional': None, |
52 'RuntimeEnabled': None, | 52 'RuntimeEnabled': None, |
53 } | 53 } |
54 default_parameters = { | 54 default_parameters = { |
55 'namespace': '', | 55 'namespace': '', |
| 56 'suffix': '', |
56 } | 57 } |
57 filters = { | 58 filters = { |
58 'cpp_name': name_utilities.cpp_name, | 59 'cpp_name': name_utilities.cpp_name, |
59 'enable_conditional': name_utilities.enable_conditional_if_endif, | 60 'enable_conditional': name_utilities.enable_conditional_if_endif, |
60 'lower_first': name_utilities.lower_first, | 61 'lower_first': name_utilities.lower_first, |
61 'case_insensitive_matching': case_insensitive_matching, | 62 'case_insensitive_matching': case_insensitive_matching, |
62 'script_name': name_utilities.script_name, | 63 'script_name': name_utilities.script_name, |
63 } | 64 } |
64 | 65 |
65 def __init__(self, in_file_path): | 66 def __init__(self, in_file_path): |
66 super(EventFactoryWriter, self).__init__(in_file_path) | 67 super(EventFactoryWriter, self).__init__(in_file_path) |
67 self._outputs[(self.namespace + ".cpp")] = self.generate_implementation | 68 self._outputs[(self.namespace + self.suffix + ".cpp")] = self.generate_i
mplementation |
68 | 69 |
69 @template_expander.use_jinja('EventFactory.cpp.tmpl', filters=filters) | 70 @template_expander.use_jinja('EventFactory.cpp.tmpl', filters=filters) |
70 def generate_implementation(self): | 71 def generate_implementation(self): |
71 return { | 72 return { |
72 'namespace': self.namespace, | 73 'namespace': self.namespace, |
| 74 'suffix': self.suffix, |
73 'events': self.in_file.name_dictionaries, | 75 'events': self.in_file.name_dictionaries, |
74 } | 76 } |
75 | 77 |
76 | 78 |
77 if __name__ == "__main__": | 79 if __name__ == "__main__": |
78 name_macros.Maker(EventFactoryWriter).main(sys.argv) | 80 name_macros.Maker(EventFactoryWriter).main(sys.argv) |
OLD | NEW |