mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-22 17:23:06 +00:00
libdrgn: python: add documentation and type annotation for Program.__contains__()
drgn.Program has supported the "in" operator since commit 25e7a9d3b8
("libdrgn/python: implement Program.__contains__"), but it's
undocumented and unannotated. Add a type annotation with a docstring
along with a METH_COEXIST method.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
This commit is contained in:
parent
179b33c76f
commit
ad37c79cba
10
_drgn.pyi
10
_drgn.pyi
@ -105,7 +105,15 @@ class Program:
|
||||
>>> prog['jiffies']
|
||||
Object(prog, 'volatile unsigned long', address=0xffffffff94c05000)
|
||||
|
||||
:param name: The object name.
|
||||
:param name: Object name.
|
||||
"""
|
||||
...
|
||||
def __contains__(self, name: str) -> bool:
|
||||
"""
|
||||
Implement ``name in self``. Return whether an object (variable,
|
||||
constant, or function) with the given name exists in the program.
|
||||
|
||||
:param name: Object name.
|
||||
"""
|
||||
...
|
||||
def variable(self, name: str, filename: Optional[str] = None) -> Object:
|
||||
|
@ -879,6 +879,8 @@ static PyMethodDef Program_methods[] = {
|
||||
drgn_Program_load_default_debug_info_DOC},
|
||||
{"__getitem__", (PyCFunction)Program_subscript, METH_O | METH_COEXIST,
|
||||
drgn_Program___getitem___DOC},
|
||||
{"__contains__", (PyCFunction)Program_contains, METH_O | METH_COEXIST,
|
||||
drgn_Program___contains___DOC},
|
||||
{"read", (PyCFunction)Program_read, METH_VARARGS | METH_KEYWORDS,
|
||||
drgn_Program_read_DOC},
|
||||
#define METHOD_DEF_READ(x) \
|
||||
@ -950,7 +952,6 @@ static PyMappingMethods Program_as_mapping = {
|
||||
.mp_subscript = (binaryfunc)Program_subscript,
|
||||
};
|
||||
|
||||
|
||||
static PySequenceMethods Program_as_sequence = {
|
||||
.sq_contains = (objobjproc)Program_contains,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user