diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-06-30 13:03:54 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-06-30 16:28:14 -0700 |
commit | bc4201a7f1e93d6afb62caa8ce81bb1b0211b70c (patch) | |
tree | e630b202d1e35803a87cb1306517f79d91dbe0de /mesonbuild/modules | |
parent | 4a0a6a80837af1b75db3b3b57a5b8f41386e5c0b (diff) | |
download | meson-bc4201a7f1e93d6afb62caa8ce81bb1b0211b70c.zip meson-bc4201a7f1e93d6afb62caa8ce81bb1b0211b70c.tar.gz meson-bc4201a7f1e93d6afb62caa8ce81bb1b0211b70c.tar.bz2 |
interpreter: add required and disabled to import
This is useful both from the perspective of optional functionality that
requires a module, and also as I continue to progress with Meson++,
which will probably not implement all of the modules that Meson itself
does.
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r-- | mesonbuild/modules/__init__.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index ab8534e..19de1bd 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -106,6 +106,7 @@ class ModuleObject(HoldableObject): class MutableModuleObject(ModuleObject): pass + # FIXME: Port all modules to stop using self.interpreter and use API on # ModuleState instead. Modules should stop using this class and instead use # ModuleObject base class. @@ -119,7 +120,11 @@ class ExtensionModule(ModuleObject): @noPosargs @noKwargs - def found_method(self, args: T.List['TYPE_var'], kwargs: 'TYPE_kwargs') -> bool: + def found_method(self, state: 'ModuleState', args: T.List['TYPE_var'], kwargs: 'TYPE_kwargs') -> bool: + return self.found() + + @staticmethod + def found() -> bool: return True @@ -130,7 +135,7 @@ class NewExtensionModule(ModuleObject): provides the found method. """ - def __init__(self): + def __init__(self) -> None: super().__init__() self.methods.update({ 'found': self.found_method, @@ -138,26 +143,23 @@ class NewExtensionModule(ModuleObject): @noPosargs @noKwargs - def found_method(self, args: T.List['TYPE_var'], kwargs: 'TYPE_kwargs') -> bool: + def found_method(self, state: 'ModuleState', args: T.List['TYPE_var'], kwargs: 'TYPE_kwargs') -> bool: + return self.found() + + @staticmethod + def found() -> bool: return True -class NotFoundExtensionModule(ModuleObject): +class NotFoundExtensionModule(NewExtensionModule): """Class for modern modules provides the found method. """ - def __init__(self): - super().__init__() - self.methods.update({ - 'found': self.found_method, - }) - - @noPosargs - @noKwargs - def found_method(self, args: T.List['TYPE_var'], kwargs: 'TYPE_kwargs') -> bool: + @staticmethod + def found() -> bool: return False |