File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -2001,6 +2001,43 @@ The generated glue code looks like this:
2001
2001
.. versionadded :: 3.13
2002
2002
2003
2003
2004
+ .. _clinic-howto-getter :
2005
+
2006
+ How to generate getter with Argument Clinic
2007
+ --------------------------------------------
2008
+
2009
+ You can use ``@getter `` directive to generate "impl" function
2010
+ to defining getter.
2011
+
2012
+ Example from :cpy-file: `Modules/_io/bufferedio.c `::
2013
+
2014
+ /*[clinic input]
2015
+ @critical_section
2016
+ @getter
2017
+ _io._Buffered.closed
2018
+ [clinic start generated code]*/
2019
+
2020
+ The generate glue code looks like this.
2021
+ Note that this example is mixture usage with ``@critical_section `` directive
2022
+ to achieve thread safety without causing deadlocks between threads:
2023
+
2024
+ .. code-block :: c
2025
+
2026
+ static PyObject *
2027
+ _io__Buffered_closed_get(buffered *self, void *context)
2028
+ {
2029
+ PyObject *return_value = NULL;
2030
+
2031
+ Py_BEGIN_CRITICAL_SECTION(self);
2032
+ return_value = _io__Buffered_closed_get_impl(self);
2033
+ Py_END_CRITICAL_SECTION();
2034
+
2035
+ return return_value;
2036
+ }
2037
+
2038
+ .. versionadded :: 3.13
2039
+
2040
+
2004
2041
.. _clinic-howto-deprecate-positional :
2005
2042
.. _clinic-howto-deprecate-keyword :
2006
2043
You can’t perform that action at this time.
0 commit comments