| 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 19 matching lines...) Expand all Loading... |
| 30 import os.path | 30 import os.path |
| 31 import sys | 31 import sys |
| 32 import shutil | 32 import shutil |
| 33 | 33 |
| 34 from in_file import InFile | 34 from in_file import InFile |
| 35 import name_macros | 35 import name_macros |
| 36 import name_utilities | 36 import name_utilities |
| 37 import template_expander | 37 import template_expander |
| 38 | 38 |
| 39 | 39 |
| 40 def case_insensitive_matching(name): |
| 41 return (name == ('HTMLEvents') |
| 42 or name == 'Event' |
| 43 or name == 'Events' |
| 44 or name.startswith('UIEvent') |
| 45 or name.startswith('CustomEvent') |
| 46 or name.startswith('MouseEvent')) |
| 47 |
| 40 class EventFactoryWriter(name_macros.Writer): | 48 class EventFactoryWriter(name_macros.Writer): |
| 41 defaults = { | 49 defaults = { |
| 42 'ImplementedAs': None, | 50 'ImplementedAs': None, |
| 43 'Conditional': None, | 51 'Conditional': None, |
| 44 'RuntimeEnabled': None, | 52 'RuntimeEnabled': None, |
| 45 } | 53 } |
| 46 default_parameters = { | 54 default_parameters = { |
| 47 'namespace': '', | 55 'namespace': '', |
| 48 } | 56 } |
| 49 filters = { | 57 filters = { |
| 50 'cpp_name': name_utilities.cpp_name, | 58 'cpp_name': name_utilities.cpp_name, |
| 51 'enable_conditional': name_utilities.enable_conditional_if_endif, | 59 'enable_conditional': name_utilities.enable_conditional_if_endif, |
| 52 'lower_first': name_utilities.lower_first, | 60 'lower_first': name_utilities.lower_first, |
| 61 'case_insensitive_matching': case_insensitive_matching, |
| 53 'script_name': name_utilities.script_name, | 62 'script_name': name_utilities.script_name, |
| 54 } | 63 } |
| 55 | 64 |
| 56 def __init__(self, in_file_path): | 65 def __init__(self, in_file_path): |
| 57 super(EventFactoryWriter, self).__init__(in_file_path) | 66 super(EventFactoryWriter, self).__init__(in_file_path) |
| 58 self._outputs[(self.namespace + ".cpp")] = self.generate_implementation | 67 self._outputs[(self.namespace + ".cpp")] = self.generate_implementation |
| 59 | 68 |
| 60 @template_expander.use_jinja('EventFactory.cpp.tmpl', filters=filters) | 69 @template_expander.use_jinja('EventFactory.cpp.tmpl', filters=filters) |
| 61 def generate_implementation(self): | 70 def generate_implementation(self): |
| 62 return { | 71 return { |
| 63 'namespace': self.namespace, | 72 'namespace': self.namespace, |
| 64 'events': self.in_file.name_dictionaries, | 73 'events': self.in_file.name_dictionaries, |
| 65 } | 74 } |
| 66 | 75 |
| 67 | 76 |
| 68 if __name__ == "__main__": | 77 if __name__ == "__main__": |
| 69 name_macros.Maker(EventFactoryWriter).main(sys.argv) | 78 name_macros.Maker(EventFactoryWriter).main(sys.argv) |
| OLD | NEW |