aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/options.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2024-06-08 21:31:10 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2024-06-08 22:58:06 +0300
commit2b1510d7068747541f8d49ba876570d62fde5d0e (patch)
tree57672ec9b21c3381fa40c5ed26530f672d4ce6af /mesonbuild/options.py
parent374fa7f0da278d46a4c3adb587f4b43089f5d7db (diff)
downloadmeson-2b1510d7068747541f8d49ba876570d62fde5d0e.zip
meson-2b1510d7068747541f8d49ba876570d62fde5d0e.tar.gz
meson-2b1510d7068747541f8d49ba876570d62fde5d0e.tar.bz2
Convert option from a plain dictionary into a named class.
Diffstat (limited to 'mesonbuild/options.py')
-rw-r--r--mesonbuild/options.py41
1 files changed, 38 insertions, 3 deletions
diff --git a/mesonbuild/options.py b/mesonbuild/options.py
index 2699dd5..6ffcf1a 100644
--- a/mesonbuild/options.py
+++ b/mesonbuild/options.py
@@ -25,6 +25,7 @@ from .mesonlib import (
from . import mlog
import typing as T
+from typing import ItemsView
DEFAULT_YIELDING = False
@@ -473,8 +474,42 @@ BUILTIN_DIR_NOPREFIX_OPTIONS: T.Dict[OptionKey, T.Dict[str, str]] = {
OptionKey('purelibdir', module='python'): {},
}
-
class OptionStore:
def __init__(self):
- # This class will hold all options for a given build directory
- self.dummy = None
+ self.d: T.Dict['OptionKey', 'UserOption[T.Any]'] = {}
+
+ def __len__(self):
+ return len(self.d)
+
+ def __setitem__(self, key, value):
+ self.d[key] = value
+
+ def __getitem__(self, key):
+ return self.d[key]
+
+ def __delitem__(self, key):
+ del self.d[key]
+
+ def __contains__(self, key):
+ return key in self.d
+
+ def __repr__(self):
+ return repr(self.d)
+
+ def keys(self):
+ return self.d.keys()
+
+ def values(self):
+ return self.d.values()
+
+ def items(self) -> ItemsView['OptionKey', 'USerOption[T.Any]']:
+ return self.d.items()
+
+ def update(self, *args, **kwargs):
+ return self.d.update(*args, **kwargs)
+
+ def setdefault(self, k, o):
+ return self.d.setdefault(k, o)
+
+ def get(self, *args, **kwargs)-> UserOption:
+ return self.d.get(*args, **kwargs)