aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreterbase/helpers.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-08-27 17:07:40 -0400
committerXavier Claessens <xclaesse@gmail.com>2021-08-30 14:00:54 -0400
commitf8cfd91d719b2916355da44dda4870b9518ff905 (patch)
tree48dc83647896d15c1a14f9e3e1944e9163c42b1a /mesonbuild/interpreterbase/helpers.py
parentab773ff9e8cecce7c761e8d99652869862fa8cad (diff)
downloadmeson-f8cfd91d719b2916355da44dda4870b9518ff905.zip
meson-f8cfd91d719b2916355da44dda4870b9518ff905.tar.gz
meson-f8cfd91d719b2916355da44dda4870b9518ff905.tar.bz2
Simplify get_callee_args
Diffstat (limited to 'mesonbuild/interpreterbase/helpers.py')
-rw-r--r--mesonbuild/interpreterbase/helpers.py55
1 files changed, 0 insertions, 55 deletions
diff --git a/mesonbuild/interpreterbase/helpers.py b/mesonbuild/interpreterbase/helpers.py
index 2352577..3d45e1f 100644
--- a/mesonbuild/interpreterbase/helpers.py
+++ b/mesonbuild/interpreterbase/helpers.py
@@ -61,58 +61,3 @@ def default_resolve_key(key: mparser.BaseNode) -> str:
if not isinstance(key, mparser.IdNode):
raise InterpreterException('Invalid kwargs format.')
return key.value
-
-def get_callee_args(wrapped_args: T.Sequence[T.Any], want_subproject: bool = False) -> T.Tuple[T.Any, mparser.BaseNode, T.List['TYPE_var'], 'TYPE_kwargs', T.Optional[str]]:
- s = wrapped_args[0]
- n = len(wrapped_args)
- # Raise an error if the codepaths are not there
- subproject = None # type: T.Optional[str]
- if want_subproject and n == 2:
- if hasattr(s, 'subproject'):
- # Interpreter base types have 2 args: self, node
- node = wrapped_args[1]
- # args and kwargs are inside the node
- args = None
- kwargs = None
- subproject = s.subproject
- elif hasattr(wrapped_args[1], 'subproject'):
- # Module objects have 2 args: self, interpreter
- node = wrapped_args[1].current_node
- # args and kwargs are inside the node
- args = None
- kwargs = None
- subproject = wrapped_args[1].subproject
- else:
- raise AssertionError(f'Unknown args: {wrapped_args!r}')
- elif n == 3:
- # Methods on objects (*Holder, MesonMain, etc) have 3 args: self, args, kwargs
- node = s.current_node
- args = wrapped_args[1]
- kwargs = wrapped_args[2]
- if want_subproject:
- if hasattr(s, 'subproject'):
- subproject = s.subproject
- elif hasattr(s, 'interpreter'):
- subproject = s.interpreter.subproject
- elif n == 4:
- # Meson functions have 4 args: self, node, args, kwargs
- # Module functions have 4 args: self, state, args, kwargs
- from .interpreterbase import InterpreterBase # TODO: refactor to avoid this import
- if isinstance(s, InterpreterBase):
- node = wrapped_args[1]
- else:
- node = wrapped_args[1].current_node
- args = wrapped_args[2]
- kwargs = wrapped_args[3]
- if want_subproject:
- if isinstance(s, InterpreterBase):
- subproject = s.subproject
- else:
- subproject = wrapped_args[1].subproject
- else:
- raise AssertionError(f'Unknown args: {wrapped_args!r}')
- # Sometimes interpreter methods are called internally with None instead of
- # empty list/dict
- args = args if args is not None else []
- kwargs = kwargs if kwargs is not None else {}
- return s, node, args, kwargs, subproject