templates: move initializer to base class
Every class implements the exact same initializer, simplify this by putting it in the base class initializer
This commit is contained in:
parent
3fdc877e8a
commit
d0729bde02
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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!')
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue