From b34af05fccd2b91f24c863b4d6e2c1e39b62ddb2 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 8 Dec 2022 01:16:52 +0530 Subject: [PATCH 1/4] updated the writing style PyMethodDef --- Doc/c-api/structures.rst | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 827d624fc99edb..a688b345f3b3ff 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -228,29 +228,30 @@ Implementing functions and methods Structure used to describe a method of an extension type. This structure has four fields: - +------------------+---------------+-------------------------------+ - | Field | C Type | Meaning | - +==================+===============+===============================+ - | :attr:`ml_name` | const char \* | name of the method | - +------------------+---------------+-------------------------------+ - | :attr:`ml_meth` | PyCFunction | pointer to the C | - | | | implementation | - +------------------+---------------+-------------------------------+ - | :attr:`ml_flags` | int | flag bits indicating how the | - | | | call should be constructed | - +------------------+---------------+-------------------------------+ - | :attr:`ml_doc` | const char \* | points to the contents of the | - | | | docstring | - +------------------+---------------+-------------------------------+ - -The :attr:`ml_meth` is a C function pointer. The functions may be of different + .. c:member:: const char* 'PyMethodDef.ml_name' + + name of the method + + .. c:member:: PyCFunction 'PyMethodDef.ml_meth' + + pointer to the C implementation + + .. c:member:: int 'PyMethodDef.ml_flags' + + flags bits indicating how the call should be constructed + + .. c:member:: const char* 'PyMethodDef.ml_doc' + + points to the contents of the docstring + +The :c:member:`PyMethodDef.ml_meth` is a C function pointer. The functions may be of different types, but they always return :c:expr:`PyObject*`. If the function is not of the :c:type:`PyCFunction`, the compiler will require a cast in the method table. Even though :c:type:`PyCFunction` defines the first parameter as :c:expr:`PyObject*`, it is common that the method implementation uses the specific C type of the *self* object. -The :attr:`ml_flags` field is a bitfield which can include the following flags. +The :c:member:`PyMethodDef.ml_flags` field is a bitfield which can include the following flags. The individual flags indicate either a calling convention or a binding convention. From 32786edfa1781fbbd5e197178b7ae82804174741 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 8 Dec 2022 01:21:33 +0530 Subject: [PATCH 2/4] Update structures.rst --- Doc/c-api/structures.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index a688b345f3b3ff..38ce33550837ae 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -242,7 +242,7 @@ Implementing functions and methods .. c:member:: const char* 'PyMethodDef.ml_doc' - points to the contents of the docstring + points to the contents of the docstring The :c:member:`PyMethodDef.ml_meth` is a C function pointer. The functions may be of different types, but they always return :c:expr:`PyObject*`. If the function is not of From f87e767a2002a6a0af56366290cdbfd3c5123841 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 8 Dec 2022 01:32:29 +0530 Subject: [PATCH 3/4] Update structures.rst --- Doc/c-api/structures.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 38ce33550837ae..4af10fa670d6b3 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -228,19 +228,19 @@ Implementing functions and methods Structure used to describe a method of an extension type. This structure has four fields: - .. c:member:: const char* 'PyMethodDef.ml_name' + .. c:member:: const char* PyMethodDef.ml_name name of the method - .. c:member:: PyCFunction 'PyMethodDef.ml_meth' + .. c:member:: PyCFunction PyMethodDef.ml_meth pointer to the C implementation - .. c:member:: int 'PyMethodDef.ml_flags' + .. c:member:: int PyMethodDef.ml_flags flags bits indicating how the call should be constructed - .. c:member:: const char* 'PyMethodDef.ml_doc' + .. c:member:: const char* PyMethodDef.ml_doc points to the contents of the docstring From 24a009517d5e27c4e458e549c30d4064ccd0eb35 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Fri, 9 Dec 2022 21:01:21 +0530 Subject: [PATCH 4/4] Update structures.rst --- Doc/c-api/structures.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 4af10fa670d6b3..be6e7b5faf9f79 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -228,30 +228,30 @@ Implementing functions and methods Structure used to describe a method of an extension type. This structure has four fields: - .. c:member:: const char* PyMethodDef.ml_name + .. c:member:: const char* ml_name name of the method - .. c:member:: PyCFunction PyMethodDef.ml_meth + .. c:member:: PyCFunction ml_meth pointer to the C implementation - .. c:member:: int PyMethodDef.ml_flags + .. c:member:: int ml_flags flags bits indicating how the call should be constructed - .. c:member:: const char* PyMethodDef.ml_doc + .. c:member:: const char* ml_doc points to the contents of the docstring -The :c:member:`PyMethodDef.ml_meth` is a C function pointer. The functions may be of different +The :c:member:`ml_meth` is a C function pointer. The functions may be of different types, but they always return :c:expr:`PyObject*`. If the function is not of the :c:type:`PyCFunction`, the compiler will require a cast in the method table. Even though :c:type:`PyCFunction` defines the first parameter as :c:expr:`PyObject*`, it is common that the method implementation uses the specific C type of the *self* object. -The :c:member:`PyMethodDef.ml_flags` field is a bitfield which can include the following flags. +The :c:member:`ml_flags` field is a bitfield which can include the following flags. The individual flags indicate either a calling convention or a binding convention.