Chromium Code Reviews| Index: Source/core/scripts/make_event_factory.py |
| diff --git a/Source/core/scripts/make_event_factory.py b/Source/core/scripts/make_event_factory.py |
| index c5a5f0b1e089c85a3274d9afe5d7e69612891dba..e772d192e315214b06ae292b69122b41a8e2dbd5 100644 |
| --- a/Source/core/scripts/make_event_factory.py |
| +++ b/Source/core/scripts/make_event_factory.py |
| @@ -34,25 +34,7 @@ import shutil |
| from in_file import InFile |
| import in_generator |
| import license |
| - |
| - |
| -IMPLEMENTATION_TEMPLATE = """%(license)s |
| -#include "config.h" |
| -#include "%(namespace)sFactory.h" |
| - |
| -#include "%(namespace)sHeaders.h" |
| -#include "RuntimeEnabledFeatures.h" |
| - |
| -namespace WebCore { |
| - |
| -PassRefPtr<%(namespace)s> %(namespace)sFactory::create(const String& type) |
| -{ |
| -%(factory_implementation)s |
| - return 0; |
| -} |
| - |
| -} // namespace WebCore |
| -""" |
| +import template_expander |
| class EventFactoryWriter(in_generator.Writer): |
| @@ -66,36 +48,26 @@ class EventFactoryWriter(in_generator.Writer): |
| } |
| class_name = 'EventFactory' |
| + def __init__(self, in_file_path): |
| + super(EventFactoryWriter, self).__init__(in_file_path) |
| + self._events = self.in_file.name_dictionaries |
| + for event in self._events: |
| + event['name'] = os.path.basename(event['name']) |
| + event['interfaceName'] = event['interfaceName'] or event['name'] |
| + |
| def _namespace(self): |
| return self.in_file.parameters['namespace'] |
| - def _events(self): |
| - return self.in_file.name_dictionaries |
| - |
| - def _factory_implementation(self, event): |
| - runtime_condition = '' |
| - if event['runtimeConditional']: |
| - runtime_condition = ' && RuntimeEnabledFeatures::' + event['runtimeConditional'] + '()' |
| - name = os.path.basename(event['name']) |
| - interface_name = event['interfaceName'] if event['interfaceName'] else name |
| - implementation = """ if (type == "%(name)s"%(runtime_condition)s) |
| - return %(interface_name)s::create();""" % { |
| - 'name': name, |
| - 'runtime_condition': runtime_condition, |
| - 'interface_name': interface_name, |
| - } |
| - return self.wrap_with_condition(implementation, event['conditional']) |
| - |
| def generate_header(self): |
| pass |
| def generate_implementation(self): |
| - return IMPLEMENTATION_TEMPLATE % { |
| + params = { |
| 'namespace': self._namespace().strip('"'), |
| 'license': license.license_for_generated_cpp(), |
| - 'factory_implementation': "\n".join(map(self._factory_implementation, self._events())), |
| + 'events': self._events, |
| } |
| - |
| + return template_expander.applytemplate("../dom/EventFactory.cpp.tmpl", params) |
|
abarth-chromium
2013/05/06 18:27:32
Should we receive the path to EventFactory.cpp.tmp
|
| if __name__ == "__main__": |
| in_generator.Maker(EventFactoryWriter).main(sys.argv) |