defaults = { 'ImplementedAs': None, 'Conditional': None, 'RuntimeEnabled': None, } default_parameters = { 'namespace': '', } filters = { 'cpp_name': name_utilities.cpp_name, 'enable_conditional': name_utilities.enable_conditional_if_endif, 'lower_first': name_utilities.lower_first, 'case_insensitive_matching': case_insensitive_matching, 'script_name': name_utilities.script_name, } def __init__(self, in_file_path): super(EventFactoryWriter, self).__init__(in_file_path) self._outputs[(self.namespace + ".cpp")] = self.generate_implementation @template_expander.use_jinja('EventFactory.cpp.tmpl', filters=filters) def generate_implementation(self): return { 'namespace': self.namespace, 'events': self.in_file.name_dictionaries, } if __name__ == "__main__": name_macros.Maker(EventFactoryWriter).main(sys.argv)
exception) + '"' return self.wrap_with_condition(include, exception['conditional']) def _description_initalization(self, exception): name = os.path.basename(exception['name']) if name == 'DOMException': return '' # DOMException needs to be last because it's a catch-all. description_initalization = """ if (%(name)s::initializeDescription(ec, this)) return;""" % { 'name': name } return self.wrap_with_condition(description_initalization, exception['conditional']) def generate_implementation(self): return IMPLEMENTATION_TEMPLATE % { 'license': license.license_for_generated_cpp(), 'class_name': self.class_name, 'includes': '\n'.join(map(self._include, self._exceptions())), 'description_initalizations': '\n'.join(map(self._description_initalization, self._exceptions())), } if __name__ == "__main__": name_macros.Maker(ExceptionCodeDescriptionWriter).main(sys.argv)