From ababc2aa39d699687bb56984acd56f6b9f7b741b Mon Sep 17 00:00:00 2001 From: Alexandru Fikl <alexfikl@gmail.com> Date: Thu, 14 Nov 2019 11:37:52 -0600 Subject: [PATCH] constants: make to_string handle more values This is mostly implemented for `clGetKernelArgInfo` [1] called with `CL_KERNEL_ARG_TYPE_QUALIFIER`. Since an argument can have multiple type qualifiers (e.g. `const` and `volatile`), this returns the bitwise or of the flags that we need to separate. [1] https://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/clGetKernelArgInfo.html --- pyopencl/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 02fa08e1..0b68de82 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -1269,9 +1269,16 @@ def _add_functionality(): } def to_string(cls, value, default_format=None): + names = [] for name in dir(cls): - if (not name.startswith("_") and getattr(cls, name) == value): - return name + attr = getattr(cls, name) + if name.startswith('_') or type(attr) is not type(value): + continue + if attr == value or attr & value: + names.append(name) + + if names: + return " ".join(names) if default_format is None: raise ValueError("a name for value %d was not found in %s" -- GitLab