modules: Make ExtensionModule inherit from NewExtensionModule

It reduces duplicated code.
pull/10047/head
Xavier Claessens 3 years ago committed by Xavier Claessens
parent 904b47085f
commit ad75a2bfec
  1. 29
      mesonbuild/modules/__init__.py

@ -126,28 +126,6 @@ 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.
class ExtensionModule(ModuleObject):
def __init__(self, interpreter: 'Interpreter') -> None:
super().__init__()
self.interpreter = interpreter
self.methods.update({
'found': self.found_method,
})
@noPosargs
@noKwargs
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 NewExtensionModule(ModuleObject):
"""Class for modern modules
@ -170,6 +148,13 @@ class NewExtensionModule(ModuleObject):
def found() -> bool:
return True
# 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.
class ExtensionModule(NewExtensionModule):
def __init__(self, interpreter: 'Interpreter') -> None:
super().__init__()
self.interpreter = interpreter
class NotFoundExtensionModule(NewExtensionModule):

Loading…
Cancel
Save