diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2023-06-30 14:33:43 -0700 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2023-07-25 15:50:21 -0400 |
commit | d0729bde02a4fd7708fc9fce2dd779e9fb9ab342 (patch) | |
tree | ef096e5f97010ee8e0cfc774a35b088409cbe055 /mesonbuild/templates | |
parent | 3fdc877e8a971b3849784797dcc87045aefcd42a (diff) | |
download | meson-d0729bde02a4fd7708fc9fce2dd779e9fb9ab342.zip meson-d0729bde02a4fd7708fc9fce2dd779e9fb9ab342.tar.gz meson-d0729bde02a4fd7708fc9fce2dd779e9fb9ab342.tar.bz2 |
templates: move initializer to base class
Every class implements the exact same initializer, simplify this by
putting it in the base class initializer
Diffstat (limited to 'mesonbuild/templates')
-rw-r--r-- | mesonbuild/templates/cpptemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/cstemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/ctemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/cudatemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/dlangtemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/fortrantemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/javatemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/objcpptemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/objctemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/rusttemplates.py | 7 | ||||
-rw-r--r-- | mesonbuild/templates/sampleimpl.py | 10 | ||||
-rw-r--r-- | mesonbuild/templates/valatemplates.py | 7 |
12 files changed, 32 insertions, 55 deletions
diff --git a/mesonbuild/templates/cpptemplates.py b/mesonbuild/templates/cpptemplates.py index 6e97761..75a5ee2 100644 --- a/mesonbuild/templates/cpptemplates.py +++ b/mesonbuild/templates/cpptemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + hello_cpp_template = '''#include <iostream> @@ -143,10 +144,6 @@ pkg_mod.generate( class CppProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) diff --git a/mesonbuild/templates/cstemplates.py b/mesonbuild/templates/cstemplates.py index df09f61..39653d4 100644 --- a/mesonbuild/templates/cstemplates.py +++ b/mesonbuild/templates/cstemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + hello_cs_template = '''using System; @@ -92,10 +93,6 @@ test('{test_name}', test_exe) class CSharpProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) diff --git a/mesonbuild/templates/ctemplates.py b/mesonbuild/templates/ctemplates.py index 0c7141a..16e6c44 100644 --- a/mesonbuild/templates/ctemplates.py +++ b/mesonbuild/templates/ctemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + lib_h_template = '''#pragma once #if defined _WIN32 || defined __CYGWIN__ @@ -126,10 +127,6 @@ test('basic', exe) class CProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) diff --git a/mesonbuild/templates/cudatemplates.py b/mesonbuild/templates/cudatemplates.py index 63abd2b..ce77504 100644 --- a/mesonbuild/templates/cudatemplates.py +++ b/mesonbuild/templates/cudatemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + hello_cuda_template = '''#include <iostream> @@ -143,10 +144,6 @@ pkg_mod.generate( class CudaProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) diff --git a/mesonbuild/templates/dlangtemplates.py b/mesonbuild/templates/dlangtemplates.py index 81840fe..d5adf92 100644 --- a/mesonbuild/templates/dlangtemplates.py +++ b/mesonbuild/templates/dlangtemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + hello_d_template = '''module main; import std.stdio; @@ -104,10 +105,6 @@ endif class DlangProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) diff --git a/mesonbuild/templates/fortrantemplates.py b/mesonbuild/templates/fortrantemplates.py index 00cd509..6c21cad 100644 --- a/mesonbuild/templates/fortrantemplates.py +++ b/mesonbuild/templates/fortrantemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + lib_fortran_template = ''' ! This procedure will not be exported and is not ! directly callable by users of this library. @@ -103,10 +104,6 @@ test('basic', exe) class FortranProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) diff --git a/mesonbuild/templates/javatemplates.py b/mesonbuild/templates/javatemplates.py index 58d48ba..4b9c746 100644 --- a/mesonbuild/templates/javatemplates.py +++ b/mesonbuild/templates/javatemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + hello_java_template = ''' @@ -96,10 +97,6 @@ test('{test_name}', test_jar) class JavaProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) diff --git a/mesonbuild/templates/objcpptemplates.py b/mesonbuild/templates/objcpptemplates.py index 450f2b0..4ec785c 100644 --- a/mesonbuild/templates/objcpptemplates.py +++ b/mesonbuild/templates/objcpptemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + lib_h_template = '''#pragma once #if defined _WIN32 || defined __CYGWIN__ @@ -126,10 +127,6 @@ test('basic', exe) class ObjCppProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) diff --git a/mesonbuild/templates/objctemplates.py b/mesonbuild/templates/objctemplates.py index 2e03526..331b76c 100644 --- a/mesonbuild/templates/objctemplates.py +++ b/mesonbuild/templates/objctemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + lib_h_template = '''#pragma once #if defined _WIN32 || defined __CYGWIN__ @@ -126,10 +127,6 @@ test('basic', exe) class ObjCProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) diff --git a/mesonbuild/templates/rusttemplates.py b/mesonbuild/templates/rusttemplates.py index 0dde547..8408359 100644 --- a/mesonbuild/templates/rusttemplates.py +++ b/mesonbuild/templates/rusttemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + lib_rust_template = '''#![crate_name = "{crate_file}"] @@ -74,10 +75,6 @@ test('basic', exe) class RustProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) diff --git a/mesonbuild/templates/sampleimpl.py b/mesonbuild/templates/sampleimpl.py index 9702ae8..4d586b1 100644 --- a/mesonbuild/templates/sampleimpl.py +++ b/mesonbuild/templates/sampleimpl.py @@ -13,8 +13,18 @@ # limitations under the License. from __future__ import annotations +import typing as T + +if T.TYPE_CHECKING: + from ..minit import Arguments + class SampleImpl: + + def __init__(self, args: Arguments): + self.name = args.name + self.version = args.version + def create_executable(self) -> None: raise NotImplementedError('Sample implementation for "executable" not implemented!') diff --git a/mesonbuild/templates/valatemplates.py b/mesonbuild/templates/valatemplates.py index ef9794d..b6a4614 100644 --- a/mesonbuild/templates/valatemplates.py +++ b/mesonbuild/templates/valatemplates.py @@ -13,9 +13,10 @@ # limitations under the License. from __future__ import annotations -from mesonbuild.templates.sampleimpl import SampleImpl import re +from mesonbuild.templates.sampleimpl import SampleImpl + hello_vala_template = '''void main (string[] args) {{ stdout.printf ("Hello {project_name}!\\n"); @@ -84,10 +85,6 @@ test('{test_name}', test_exe) class ValaProject(SampleImpl): - def __init__(self, options): - super().__init__() - self.name = options.name - self.version = options.version def create_executable(self) -> None: lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower()) |