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.startswith('Event') | |
arv (Not doing code reviews)
2014/05/05 16:06:11
Why do we get "Events" here?
arv (Not doing code reviews)
2014/05/05 16:06:11
maybe?
or name == 'Event'
or name == 'Events'
...
| |
43 or name.startswith('UIEvent') | |
44 or name.startswith('CustomEvent') | |
45 or name.startswith('MouseEvent')) | |
46 | |
40 class EventFactoryWriter(name_macros.Writer): | 47 class EventFactoryWriter(name_macros.Writer): |
41 defaults = { | 48 defaults = { |
42 'ImplementedAs': None, | 49 'ImplementedAs': None, |
43 'Conditional': None, | 50 'Conditional': None, |
44 'RuntimeEnabled': None, | 51 'RuntimeEnabled': None, |
45 } | 52 } |
46 default_parameters = { | 53 default_parameters = { |
47 'namespace': '', | 54 'namespace': '', |
48 } | 55 } |
49 filters = { | 56 filters = { |
50 'cpp_name': name_utilities.cpp_name, | 57 'cpp_name': name_utilities.cpp_name, |
51 'enable_conditional': name_utilities.enable_conditional_if_endif, | 58 'enable_conditional': name_utilities.enable_conditional_if_endif, |
52 'lower_first': name_utilities.lower_first, | 59 'lower_first': name_utilities.lower_first, |
60 'case_insensitive_matching': case_insensitive_matching, | |
53 'script_name': name_utilities.script_name, | 61 'script_name': name_utilities.script_name, |
54 } | 62 } |
55 | 63 |
56 def __init__(self, in_file_path): | 64 def __init__(self, in_file_path): |
57 super(EventFactoryWriter, self).__init__(in_file_path) | 65 super(EventFactoryWriter, self).__init__(in_file_path) |
58 self._outputs[(self.namespace + ".cpp")] = self.generate_implementation | 66 self._outputs[(self.namespace + ".cpp")] = self.generate_implementation |
59 | 67 |
60 @template_expander.use_jinja('EventFactory.cpp.tmpl', filters=filters) | 68 @template_expander.use_jinja('EventFactory.cpp.tmpl', filters=filters) |
61 def generate_implementation(self): | 69 def generate_implementation(self): |
62 return { | 70 return { |
63 'namespace': self.namespace, | 71 'namespace': self.namespace, |
64 'events': self.in_file.name_dictionaries, | 72 'events': self.in_file.name_dictionaries, |
65 } | 73 } |
66 | 74 |
67 | 75 |
68 if __name__ == "__main__": | 76 if __name__ == "__main__": |
69 name_macros.Maker(EventFactoryWriter).main(sys.argv) | 77 name_macros.Maker(EventFactoryWriter).main(sys.argv) |
OLD | NEW |