Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (C) 2013 Google Inc. All rights reserved. | 2 # Copyright (C) 2015 Google Inc. All rights reserved. |
|
haraken
2015/12/24 15:46:51
Nit: You can use the 3-line copyright.
| |
| 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 |
| 11 # copyright notice, this list of conditions and the following disclaimer | 11 # copyright notice, this list of conditions and the following disclaimer |
| 12 # in the documentation and/or other materials provided with the | 12 # in the documentation and/or other materials provided with the |
| 13 # distribution. | 13 # distribution. |
| 14 # * Neither the name of Google Inc. nor the names of its | 14 # * Neither the name of Google Inc. nor the names of its |
| 15 # contributors may be used to endorse or promote products derived from | 15 # contributors may be used to endorse or promote products derived from |
| 16 # this software without specific prior written permission. | 16 # this software without specific prior written permission. |
| 17 # | 17 # |
| 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | 29 |
| 30 import os.path | |
| 31 import sys | 30 import sys |
| 32 | 31 |
| 33 import in_generator | 32 import in_generator |
| 34 import make_runtime_features | 33 import make_runtime_features |
| 35 import name_utilities | 34 import name_utilities |
| 36 import template_expander | 35 import template_expander |
| 37 | 36 |
| 38 | 37 |
| 39 # We want exactly the same parsing as RuntimeFeatureWriter | 38 # We want exactly the same parsing as RuntimeFeatureWriter |
| 40 # but generate different files. | 39 # but generate different files. |
| 41 class InternalRuntimeFlagsWriter(make_runtime_features.RuntimeFeatureWriter): | 40 class ExperimentalFeatureWriter(make_runtime_features.RuntimeFeatureWriter): |
| 42 class_name = 'InternalRuntimeFlags' | 41 class_name = 'ExperimentalFeatures' |
| 43 filters = { | 42 filters = { |
| 44 'enable_conditional': name_utilities.enable_conditional_if_endif, | 43 'enable_conditional': name_utilities.enable_conditional_if_endif, |
| 45 } | 44 } |
| 46 | 45 |
| 47 def __init__(self, in_file_path): | 46 def __init__(self, in_file_path): |
| 48 super(InternalRuntimeFlagsWriter, self).__init__(in_file_path) | 47 super(ExperimentalFeatureWriter, self).__init__(in_file_path) |
| 49 self._outputs = {(self.class_name + '.idl'): self.generate_idl, | 48 self._outputs = { |
| 50 (self.class_name + '.h'): self.generate_header, | 49 (self.class_name + '.cpp'): self.generate_implementation, |
| 51 } | 50 (self.class_name + '.h'): self.generate_header, |
| 51 } | |
| 52 | 52 |
| 53 @template_expander.use_jinja(class_name + '.idl.tmpl') | 53 @template_expander.use_jinja(class_name + '.cpp.tmpl') |
| 54 def generate_idl(self): | 54 def generate_implementation(self): |
| 55 return { | 55 return { |
| 56 'features': self._features, | 56 'features': self._features, |
| 57 'standard_features': self._standard_features, | |
| 58 } | 57 } |
| 59 | 58 |
| 60 @template_expander.use_jinja(class_name + '.h.tmpl', filters=filters) | 59 @template_expander.use_jinja(class_name + '.h.tmpl', filters=filters) |
| 61 def generate_header(self): | 60 def generate_header(self): |
| 62 return { | 61 return { |
| 63 'features': self._features, | 62 'features': self._features, |
| 64 'feature_sets': self._feature_sets(), | |
| 65 'standard_features': self._standard_features, | |
| 66 } | 63 } |
| 67 | 64 |
| 68 | 65 |
| 69 if __name__ == '__main__': | 66 if __name__ == '__main__': |
| 70 in_generator.Maker(InternalRuntimeFlagsWriter).main(sys.argv) | 67 in_generator.Maker(ExperimentalFeatureWriter).main(sys.argv) |
| OLD | NEW |