Cython 3.3.0__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Cython/Build/BuildExecutable.py +156 -0
- Cython/Build/Cache.py +199 -0
- Cython/Build/Cythonize.py +349 -0
- Cython/Build/Dependencies.py +1281 -0
- Cython/Build/Distutils.py +1 -0
- Cython/Build/Inline.py +467 -0
- Cython/Build/IpythonMagic.py +559 -0
- Cython/Build/SharedModule.py +165 -0
- Cython/Build/Tests/TestCyCache.py +195 -0
- Cython/Build/Tests/TestCythonizeArgsParser.py +480 -0
- Cython/Build/Tests/TestDependencies.py +133 -0
- Cython/Build/Tests/TestInline.py +177 -0
- Cython/Build/Tests/TestIpythonMagic.py +303 -0
- Cython/Build/Tests/TestRecythonize.py +212 -0
- Cython/Build/Tests/TestStripLiterals.py +155 -0
- Cython/Build/Tests/__init__.py +1 -0
- Cython/Build/__init__.py +11 -0
- Cython/CodeWriter.py +825 -0
- Cython/Compiler/AnalysedTreeTransforms.py +97 -0
- Cython/Compiler/Annotate.py +328 -0
- Cython/Compiler/AutoDocTransforms.py +320 -0
- Cython/Compiler/Buffer.py +679 -0
- Cython/Compiler/Builtin.py +1102 -0
- Cython/Compiler/CmdLine.py +373 -0
- Cython/Compiler/Code.cp315-win_amd64.pyd +0 -0
- Cython/Compiler/Code.pxd +154 -0
- Cython/Compiler/Code.py +3760 -0
- Cython/Compiler/CodeGeneration.py +33 -0
- Cython/Compiler/CythonScope.py +208 -0
- Cython/Compiler/Dataclass.py +890 -0
- Cython/Compiler/DebugFlags.py +24 -0
- Cython/Compiler/Errors.py +310 -0
- Cython/Compiler/ExprNodes.py +16273 -0
- Cython/Compiler/FlowControl.cp315-win_amd64.pyd +0 -0
- Cython/Compiler/FlowControl.pxd +112 -0
- Cython/Compiler/FlowControl.py +1573 -0
- Cython/Compiler/FusedNode.cp315-win_amd64.pyd +0 -0
- Cython/Compiler/FusedNode.py +978 -0
- Cython/Compiler/Future.py +16 -0
- Cython/Compiler/Interpreter.py +57 -0
- Cython/Compiler/Lexicon.py +422 -0
- Cython/Compiler/LineTable.cp315-win_amd64.pyd +0 -0
- Cython/Compiler/LineTable.py +114 -0
- Cython/Compiler/Main.py +856 -0
- Cython/Compiler/MatchCaseNodes.py +2200 -0
- Cython/Compiler/MemoryView.py +930 -0
- Cython/Compiler/ModuleNode.py +4548 -0
- Cython/Compiler/Naming.py +370 -0
- Cython/Compiler/Nodes.py +11304 -0
- Cython/Compiler/Optimize.py +5564 -0
- Cython/Compiler/Options.py +840 -0
- Cython/Compiler/ParseTreeTransforms.pxd +80 -0
- Cython/Compiler/ParseTreeTransforms.py +4808 -0
- Cython/Compiler/Parsing.cp315-win_amd64.pyd +0 -0
- Cython/Compiler/Parsing.pxd +9 -0
- Cython/Compiler/Parsing.py +4809 -0
- Cython/Compiler/Pipeline.py +439 -0
- Cython/Compiler/PyrexTypes.py +6588 -0
- Cython/Compiler/Pythran.py +232 -0
- Cython/Compiler/Scanning.cp315-win_amd64.pyd +0 -0
- Cython/Compiler/Scanning.pxd +70 -0
- Cython/Compiler/Scanning.py +720 -0
- Cython/Compiler/StringEncoding.cp315-win_amd64.pyd +0 -0
- Cython/Compiler/StringEncoding.py +354 -0
- Cython/Compiler/Symtab.py +3121 -0
- Cython/Compiler/Tests/TestBuffer.py +105 -0
- Cython/Compiler/Tests/TestBuiltin.py +196 -0
- Cython/Compiler/Tests/TestCmdLine.py +652 -0
- Cython/Compiler/Tests/TestCode.py +145 -0
- Cython/Compiler/Tests/TestFlowControl.py +65 -0
- Cython/Compiler/Tests/TestGrammar.py +202 -0
- Cython/Compiler/Tests/TestMemView.py +71 -0
- Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
- Cython/Compiler/Tests/TestScanning.py +132 -0
- Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
- Cython/Compiler/Tests/TestStringEncoding.py +20 -0
- Cython/Compiler/Tests/TestTreeFragment.py +63 -0
- Cython/Compiler/Tests/TestTreePath.py +103 -0
- Cython/Compiler/Tests/TestTypes.py +119 -0
- Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
- Cython/Compiler/Tests/TestVisitor.py +119 -0
- Cython/Compiler/Tests/Utils.py +36 -0
- Cython/Compiler/Tests/__init__.py +1 -0
- Cython/Compiler/TreeFragment.py +279 -0
- Cython/Compiler/TreePath.py +303 -0
- Cython/Compiler/TypeInference.py +611 -0
- Cython/Compiler/TypeSlots.py +1329 -0
- Cython/Compiler/UFuncs.py +317 -0
- Cython/Compiler/UtilNodes.py +389 -0
- Cython/Compiler/UtilityCode.py +354 -0
- Cython/Compiler/Version.py +8 -0
- Cython/Compiler/Visitor.cp315-win_amd64.pyd +0 -0
- Cython/Compiler/Visitor.pxd +52 -0
- Cython/Compiler/Visitor.py +914 -0
- Cython/Compiler/__init__.py +1 -0
- Cython/Coverage.py +448 -0
- Cython/Debugger/Cygdb.py +214 -0
- Cython/Debugger/DebugWriter.py +82 -0
- Cython/Debugger/Tests/TestLibCython.py +280 -0
- Cython/Debugger/Tests/__init__.py +1 -0
- Cython/Debugger/Tests/cfuncs.c +8 -0
- Cython/Debugger/Tests/codefile +49 -0
- Cython/Debugger/Tests/test_libcython_in_gdb.py +580 -0
- Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
- Cython/Debugger/__init__.py +1 -0
- Cython/Debugger/libcython.py +1548 -0
- Cython/Debugger/libpython.py +2821 -0
- Cython/Debugging.py +20 -0
- Cython/Distutils/__init__.py +2 -0
- Cython/Distutils/build_ext.py +143 -0
- Cython/Distutils/extension.py +96 -0
- Cython/Distutils/old_build_ext.py +351 -0
- Cython/Includes/cpython/__init__.pxd +173 -0
- Cython/Includes/cpython/array.pxd +152 -0
- Cython/Includes/cpython/bool.pxd +37 -0
- Cython/Includes/cpython/buffer.pxd +112 -0
- Cython/Includes/cpython/bytearray.pxd +33 -0
- Cython/Includes/cpython/bytes.pxd +200 -0
- Cython/Includes/cpython/cellobject.pxd +35 -0
- Cython/Includes/cpython/ceval.pxd +8 -0
- Cython/Includes/cpython/codecs.pxd +121 -0
- Cython/Includes/cpython/complex.pxd +60 -0
- Cython/Includes/cpython/contextvars.pxd +145 -0
- Cython/Includes/cpython/conversion.pxd +36 -0
- Cython/Includes/cpython/datetime.pxd +395 -0
- Cython/Includes/cpython/descr.pxd +26 -0
- Cython/Includes/cpython/dict.pxd +268 -0
- Cython/Includes/cpython/exc.pxd +263 -0
- Cython/Includes/cpython/fileobject.pxd +57 -0
- Cython/Includes/cpython/float.pxd +56 -0
- Cython/Includes/cpython/frozendict.pxd +37 -0
- Cython/Includes/cpython/function.pxd +65 -0
- Cython/Includes/cpython/genobject.pxd +25 -0
- Cython/Includes/cpython/getargs.pxd +12 -0
- Cython/Includes/cpython/instance.pxd +25 -0
- Cython/Includes/cpython/iterator.pxd +36 -0
- Cython/Includes/cpython/iterobject.pxd +24 -0
- Cython/Includes/cpython/list.pxd +144 -0
- Cython/Includes/cpython/long.pxd +180 -0
- Cython/Includes/cpython/longintrepr.pxd +14 -0
- Cython/Includes/cpython/mapping.pxd +63 -0
- Cython/Includes/cpython/marshal.pxd +66 -0
- Cython/Includes/cpython/mem.pxd +120 -0
- Cython/Includes/cpython/memoryview.pxd +50 -0
- Cython/Includes/cpython/method.pxd +49 -0
- Cython/Includes/cpython/module.pxd +208 -0
- Cython/Includes/cpython/number.pxd +258 -0
- Cython/Includes/cpython/object.pxd +430 -0
- Cython/Includes/cpython/pycapsule.pxd +143 -0
- Cython/Includes/cpython/pylifecycle.pxd +68 -0
- Cython/Includes/cpython/pyport.pxd +8 -0
- Cython/Includes/cpython/pystate.pxd +95 -0
- Cython/Includes/cpython/pythread.pxd +53 -0
- Cython/Includes/cpython/ref.pxd +141 -0
- Cython/Includes/cpython/sentinel.pxd +17 -0
- Cython/Includes/cpython/sequence.pxd +134 -0
- Cython/Includes/cpython/set.pxd +119 -0
- Cython/Includes/cpython/slice.pxd +70 -0
- Cython/Includes/cpython/time.pxd +129 -0
- Cython/Includes/cpython/tuple.pxd +72 -0
- Cython/Includes/cpython/type.pxd +146 -0
- Cython/Includes/cpython/unicode.pxd +639 -0
- Cython/Includes/cpython/version.pxd +32 -0
- Cython/Includes/cpython/weakref.pxd +78 -0
- Cython/Includes/libc/__init__.pxd +1 -0
- Cython/Includes/libc/complex.pxd +35 -0
- Cython/Includes/libc/errno.pxd +127 -0
- Cython/Includes/libc/float.pxd +43 -0
- Cython/Includes/libc/limits.pxd +28 -0
- Cython/Includes/libc/locale.pxd +46 -0
- Cython/Includes/libc/math.pxd +209 -0
- Cython/Includes/libc/setjmp.pxd +10 -0
- Cython/Includes/libc/signal.pxd +64 -0
- Cython/Includes/libc/stddef.pxd +9 -0
- Cython/Includes/libc/stdint.pxd +105 -0
- Cython/Includes/libc/stdio.pxd +80 -0
- Cython/Includes/libc/stdlib.pxd +72 -0
- Cython/Includes/libc/string.pxd +50 -0
- Cython/Includes/libc/threads.pxd +234 -0
- Cython/Includes/libc/time.pxd +52 -0
- Cython/Includes/libcpp/__init__.pxd +4 -0
- Cython/Includes/libcpp/algorithm.pxd +320 -0
- Cython/Includes/libcpp/any.pxd +16 -0
- Cython/Includes/libcpp/atomic.pxd +59 -0
- Cython/Includes/libcpp/barrier.pxd +22 -0
- Cython/Includes/libcpp/bit.pxd +29 -0
- Cython/Includes/libcpp/cast.pxd +12 -0
- Cython/Includes/libcpp/cmath.pxd +518 -0
- Cython/Includes/libcpp/complex.pxd +106 -0
- Cython/Includes/libcpp/condition_variable.pxd +322 -0
- Cython/Includes/libcpp/deque.pxd +165 -0
- Cython/Includes/libcpp/exception.pxd +216 -0
- Cython/Includes/libcpp/execution.pxd +15 -0
- Cython/Includes/libcpp/forward_list.pxd +63 -0
- Cython/Includes/libcpp/functional.pxd +26 -0
- Cython/Includes/libcpp/future.pxd +103 -0
- Cython/Includes/libcpp/iterator.pxd +34 -0
- Cython/Includes/libcpp/latch.pxd +17 -0
- Cython/Includes/libcpp/limits.pxd +61 -0
- Cython/Includes/libcpp/list.pxd +117 -0
- Cython/Includes/libcpp/map.pxd +252 -0
- Cython/Includes/libcpp/memory.pxd +115 -0
- Cython/Includes/libcpp/mutex.pxd +387 -0
- Cython/Includes/libcpp/numbers.pxd +15 -0
- Cython/Includes/libcpp/numeric.pxd +131 -0
- Cython/Includes/libcpp/optional.pxd +34 -0
- Cython/Includes/libcpp/pair.pxd +1 -0
- Cython/Includes/libcpp/queue.pxd +25 -0
- Cython/Includes/libcpp/random.pxd +166 -0
- Cython/Includes/libcpp/semaphore.pxd +43 -0
- Cython/Includes/libcpp/set.pxd +228 -0
- Cython/Includes/libcpp/shared_mutex.pxd +96 -0
- Cython/Includes/libcpp/span.pxd +87 -0
- Cython/Includes/libcpp/stack.pxd +11 -0
- Cython/Includes/libcpp/stop_token.pxd +117 -0
- Cython/Includes/libcpp/string.pxd +355 -0
- Cython/Includes/libcpp/string_view.pxd +183 -0
- Cython/Includes/libcpp/typeindex.pxd +15 -0
- Cython/Includes/libcpp/typeinfo.pxd +10 -0
- Cython/Includes/libcpp/unordered_map.pxd +193 -0
- Cython/Includes/libcpp/unordered_set.pxd +152 -0
- Cython/Includes/libcpp/utility.pxd +30 -0
- Cython/Includes/libcpp/vector.pxd +186 -0
- Cython/Includes/numpy/math.pxd +150 -0
- Cython/Includes/openmp.pxd +50 -0
- Cython/Includes/posix/__init__.pxd +1 -0
- Cython/Includes/posix/dlfcn.pxd +14 -0
- Cython/Includes/posix/fcntl.pxd +86 -0
- Cython/Includes/posix/ioctl.pxd +4 -0
- Cython/Includes/posix/mman.pxd +101 -0
- Cython/Includes/posix/resource.pxd +57 -0
- Cython/Includes/posix/select.pxd +21 -0
- Cython/Includes/posix/signal.pxd +73 -0
- Cython/Includes/posix/stat.pxd +98 -0
- Cython/Includes/posix/stdio.pxd +37 -0
- Cython/Includes/posix/stdlib.pxd +29 -0
- Cython/Includes/posix/strings.pxd +9 -0
- Cython/Includes/posix/time.pxd +71 -0
- Cython/Includes/posix/types.pxd +30 -0
- Cython/Includes/posix/uio.pxd +26 -0
- Cython/Includes/posix/unistd.pxd +271 -0
- Cython/Includes/posix/wait.pxd +38 -0
- Cython/LZSS.cp315-win_amd64.pyd +0 -0
- Cython/LZSS.py +184 -0
- Cython/Plex/Actions.cp315-win_amd64.pyd +0 -0
- Cython/Plex/Actions.pxd +24 -0
- Cython/Plex/Actions.py +119 -0
- Cython/Plex/DFA.cp315-win_amd64.pyd +0 -0
- Cython/Plex/DFA.pxd +14 -0
- Cython/Plex/DFA.py +164 -0
- Cython/Plex/Errors.py +48 -0
- Cython/Plex/Lexicons.py +178 -0
- Cython/Plex/Machines.cp315-win_amd64.pyd +0 -0
- Cython/Plex/Machines.pxd +36 -0
- Cython/Plex/Machines.py +238 -0
- Cython/Plex/Regexps.py +535 -0
- Cython/Plex/Scanners.cp315-win_amd64.pyd +0 -0
- Cython/Plex/Scanners.pxd +45 -0
- Cython/Plex/Scanners.py +328 -0
- Cython/Plex/Transitions.cp315-win_amd64.pyd +0 -0
- Cython/Plex/Transitions.pxd +14 -0
- Cython/Plex/Transitions.py +239 -0
- Cython/Plex/__init__.py +34 -0
- Cython/Runtime/__init__.py +1 -0
- Cython/Runtime/refnanny.cp315-win_amd64.pyd +0 -0
- Cython/Runtime/refnanny.pyx +237 -0
- Cython/Shadow.py +1174 -0
- Cython/StringIOTree.cp315-win_amd64.pyd +0 -0
- Cython/StringIOTree.py +169 -0
- Cython/Tempita/__init__.py +4 -0
- Cython/Tempita/_looper.py +154 -0
- Cython/Tempita/_tempita.cp315-win_amd64.pyd +0 -0
- Cython/Tempita/_tempita.py +1087 -0
- Cython/TestUtils.py +472 -0
- Cython/Tests/TestCodeWriter.py +128 -0
- Cython/Tests/TestCythonUtils.py +202 -0
- Cython/Tests/TestJediTyper.py +223 -0
- Cython/Tests/TestShadow.py +125 -0
- Cython/Tests/TestStringIOTree.py +68 -0
- Cython/Tests/TestTestUtils.py +89 -0
- Cython/Tests/__init__.py +1 -0
- Cython/Tests/xmlrunner.py +390 -0
- Cython/Utility/AsyncGen.c +1152 -0
- Cython/Utility/Buffer.c +866 -0
- Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
- Cython/Utility/Builtins.c +1068 -0
- Cython/Utility/CConvert.pyx +153 -0
- Cython/Utility/CMath.c +104 -0
- Cython/Utility/CommonStructures.c +244 -0
- Cython/Utility/Complex.c +378 -0
- Cython/Utility/Coroutine.c +2344 -0
- Cython/Utility/CpdefEnums.pyx +119 -0
- Cython/Utility/CppConvert.pyx +282 -0
- Cython/Utility/CppSupport.cpp +151 -0
- Cython/Utility/CythonFunction.c +2185 -0
- Cython/Utility/Dataclasses.c +101 -0
- Cython/Utility/Embed.c +129 -0
- Cython/Utility/Exceptions.c +1331 -0
- Cython/Utility/Exceptions_Cy.pyx +109 -0
- Cython/Utility/ExtensionTypes.c +1199 -0
- Cython/Utility/FunctionArguments.c +1052 -0
- Cython/Utility/FusedFunction.pyx +44 -0
- Cython/Utility/ImportExport.c +972 -0
- Cython/Utility/MatchCase.c +981 -0
- Cython/Utility/MatchCase_Cy.pyx +12 -0
- Cython/Utility/MemoryView.pxd +108 -0
- Cython/Utility/MemoryView.pyx +1499 -0
- Cython/Utility/MemoryView_C.c +1056 -0
- Cython/Utility/ModuleSetupCode.c +3319 -0
- Cython/Utility/NumpyImportArray.c +46 -0
- Cython/Utility/ObjectHandling.c +3404 -0
- Cython/Utility/Optimize.c +2564 -0
- Cython/Utility/Overflow.c +378 -0
- Cython/Utility/Profile.c +736 -0
- Cython/Utility/StringTools.c +1534 -0
- Cython/Utility/Synchronization.c +438 -0
- Cython/Utility/TString.c +369 -0
- Cython/Utility/TestCyUtilityLoader.pyx +8 -0
- Cython/Utility/TestCythonScope.pyx +75 -0
- Cython/Utility/TestUtilityLoader.c +12 -0
- Cython/Utility/TypeConversion.c +1588 -0
- Cython/Utility/UFuncs.pyx +50 -0
- Cython/Utility/UFuncs_C.c +89 -0
- Cython/Utility/__init__.py +28 -0
- Cython/Utility/arrayarray.h +172 -0
- Cython/Utils.cp315-win_amd64.pyd +0 -0
- Cython/Utils.py +680 -0
- Cython/__init__.py +12 -0
- Cython/_shared.cp315-win_amd64.pyd +0 -0
- Cython/py.typed +0 -0
- cython-3.3.0.dist-info/METADATA +555 -0
- cython-3.3.0.dist-info/RECORD +339 -0
- cython-3.3.0.dist-info/WHEEL +5 -0
- cython-3.3.0.dist-info/entry_points.txt +4 -0
- cython-3.3.0.dist-info/top_level.txt +3 -0
- cython.py +29 -0
- pyximport/__init__.py +4 -0
- pyximport/pyxbuild.py +160 -0
- pyximport/pyximport.py +482 -0
|
@@ -0,0 +1,2185 @@
|
|
|
1
|
+
//////////////////// CythonFunctionPerModule.module_state_decls ////////////////////
|
|
2
|
+
|
|
3
|
+
PyTypeObject *__pyx_CyFunctionType;
|
|
4
|
+
|
|
5
|
+
//////////////////// CythonFunctionPerModule.module_state_traverse ///////////////////
|
|
6
|
+
|
|
7
|
+
Py_VISIT(traverse_module_state->__pyx_CyFunctionType);
|
|
8
|
+
|
|
9
|
+
//////////////////// CythonFunctionPerModule.module_state_clear ///////////////////
|
|
10
|
+
|
|
11
|
+
Py_CLEAR(clear_module_state->__pyx_CyFunctionType);
|
|
12
|
+
|
|
13
|
+
//////////////////// CythonFunctionPerModule.init //////////////////
|
|
14
|
+
//@substitute: naming
|
|
15
|
+
//@init_block: init_after_shared_utility
|
|
16
|
+
|
|
17
|
+
if (likely(__pyx_CyFunction_init($module_cname) == 0)); else
|
|
18
|
+
|
|
19
|
+
//////////////////// CythonFunctionPerModule.proto //////////////////////////
|
|
20
|
+
// This section always gets included whether we're using CythonFunction through
|
|
21
|
+
// shared utility code or not.
|
|
22
|
+
//@requires: ModuleSetupCode.c::FastTypeChecks
|
|
23
|
+
|
|
24
|
+
#define __Pyx_CyFunction_USED
|
|
25
|
+
|
|
26
|
+
#if CYTHON_OPAQUE_SHARED_TYPES
|
|
27
|
+
#define __Pyx_as_CyFunctionObject(o) ((__pyx_CyFunctionObject *)PyObject_GetTypeData((o), CGLOBAL(__pyx_CyFunctionType)))
|
|
28
|
+
#else
|
|
29
|
+
#define __Pyx_as_CyFunctionObject(o) ((__pyx_CyFunctionObject *)o)
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
|
|
33
|
+
#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
|
|
34
|
+
#define __Pyx_CYFUNCTION_CCLASS 0x04
|
|
35
|
+
#define __Pyx_CYFUNCTION_COROUTINE 0x08
|
|
36
|
+
|
|
37
|
+
#define __Pyx_CyFunction_GetClosure(f) \
|
|
38
|
+
((__Pyx_as_CyFunctionObject(f))->func_closure)
|
|
39
|
+
|
|
40
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
41
|
+
#define __Pyx__CyFunction_GetClassObj(f) \
|
|
42
|
+
((f)->func_classobj)
|
|
43
|
+
#else
|
|
44
|
+
#define __Pyx__CyFunction_GetClassObj(f) \
|
|
45
|
+
((PyObject*) ((PyCMethodObject *) (f))->mm_class)
|
|
46
|
+
#endif
|
|
47
|
+
#define __Pyx_CyFunction_GetClassObj(f) \
|
|
48
|
+
__Pyx__CyFunction_GetClassObj(__Pyx_as_CyFunctionObject(f))
|
|
49
|
+
#define __Pyx_CyFunction_SetClassObj(f, classobj) \
|
|
50
|
+
__Pyx__CyFunction_SetClassObj(__Pyx_as_CyFunctionObject(f), (classobj))
|
|
51
|
+
|
|
52
|
+
#define __Pyx_CyFunction_Defaults(type, f) \
|
|
53
|
+
((type *)((__Pyx_as_CyFunctionObject(f))->defaults))
|
|
54
|
+
#define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
|
|
55
|
+
(__Pyx_as_CyFunctionObject(f))->defaults_getter = (g)
|
|
56
|
+
|
|
57
|
+
typedef struct {
|
|
58
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
59
|
+
#if !CYTHON_OPAQUE_OBJECTS
|
|
60
|
+
PyObject_HEAD
|
|
61
|
+
#endif
|
|
62
|
+
PyMethodDef *func_methoddef;
|
|
63
|
+
PyObject *func_module;
|
|
64
|
+
#else
|
|
65
|
+
// PEP-573: PyCFunctionObject + mm_class
|
|
66
|
+
PyCMethodObject func;
|
|
67
|
+
#endif
|
|
68
|
+
#if (CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY) && CYTHON_VECTORCALL
|
|
69
|
+
__pyx_vectorcallfunc func_vectorcall;
|
|
70
|
+
#endif
|
|
71
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
72
|
+
PyObject *func_weakreflist;
|
|
73
|
+
#endif
|
|
74
|
+
#if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
|
|
75
|
+
PyObject *func_dict;
|
|
76
|
+
#endif
|
|
77
|
+
PyObject *func_name;
|
|
78
|
+
PyObject *func_qualname;
|
|
79
|
+
PyObject *func_doc;
|
|
80
|
+
PyObject *func_globals;
|
|
81
|
+
PyObject *func_code;
|
|
82
|
+
PyObject *func_closure;
|
|
83
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
84
|
+
// No-args super() class cell
|
|
85
|
+
PyObject *func_classobj;
|
|
86
|
+
#endif
|
|
87
|
+
// Dynamic default args and annotations
|
|
88
|
+
PyObject *defaults;
|
|
89
|
+
int flags;
|
|
90
|
+
|
|
91
|
+
// Defaults info
|
|
92
|
+
PyObject *defaults_tuple; /* Const defaults tuple */
|
|
93
|
+
PyObject *defaults_kwdict; /* Const kwonly defaults dict */
|
|
94
|
+
PyObject *(*defaults_getter)(PyObject *);
|
|
95
|
+
PyObject *func_annotations; /* function annotations dict */
|
|
96
|
+
|
|
97
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030B0000
|
|
98
|
+
// Coroutine marker
|
|
99
|
+
PyObject *func_is_coroutine;
|
|
100
|
+
#endif
|
|
101
|
+
} __pyx_CyFunctionObject;
|
|
102
|
+
|
|
103
|
+
#undef __Pyx_CyOrPyCFunction_Check
|
|
104
|
+
#define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, CGLOBAL(__pyx_CyFunctionType))
|
|
105
|
+
#define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, CGLOBAL(__pyx_CyFunctionType), &PyCFunction_Type)
|
|
106
|
+
#define __Pyx_CyFunction_CheckExact(obj) Py_IS_TYPE(obj, CGLOBAL(__pyx_CyFunctionType))
|
|
107
|
+
static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void));/*proto*/
|
|
108
|
+
#undef __Pyx_IsSameCFunction
|
|
109
|
+
#define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc)
|
|
110
|
+
|
|
111
|
+
static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj);
|
|
112
|
+
static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func,
|
|
113
|
+
PyTypeObject *defaults_type);
|
|
114
|
+
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
|
|
115
|
+
PyObject *tuple);
|
|
116
|
+
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
|
|
117
|
+
PyObject *dict);
|
|
118
|
+
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
|
|
119
|
+
PyObject *dict);
|
|
120
|
+
|
|
121
|
+
// Note that the actual definition of __pyx_CyFunction_init is in a different
|
|
122
|
+
// utility code section and depends on if the utility code comes from a
|
|
123
|
+
// shared module.
|
|
124
|
+
static int __pyx_CyFunction_init(PyObject *module);
|
|
125
|
+
|
|
126
|
+
#if CYTHON_VECTORCALL
|
|
127
|
+
#if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
|
|
128
|
+
#define __Pyx_CyFunction_func_vectorcall(f) ((f)->func_vectorcall)
|
|
129
|
+
#else
|
|
130
|
+
#define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
|
|
131
|
+
#endif
|
|
132
|
+
#endif
|
|
133
|
+
|
|
134
|
+
//////////////////// CythonFunctionPerModule /////////////////////
|
|
135
|
+
//@requires: ObjectHandling.c::CachedMethodType
|
|
136
|
+
|
|
137
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
138
|
+
static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) {
|
|
139
|
+
if (__Pyx_CyFunction_Check(func)) {
|
|
140
|
+
return __Pyx_as_CyFunctionObject(func)->func_methoddef->ml_meth == (PyCFunction) cfunc;
|
|
141
|
+
} else if (PyCFunction_Check(func)) {
|
|
142
|
+
return PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
|
|
143
|
+
}
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
|
|
148
|
+
if ((PyObject*)Py_TYPE(func) == CGLOBAL(__Pyx_CachedMethodType)) {
|
|
149
|
+
int result;
|
|
150
|
+
PyObject *newFunc = PyObject_GetAttr(func, PYIDENT("__func__"));
|
|
151
|
+
if (unlikely(!newFunc)) {
|
|
152
|
+
PyErr_Clear(); // It's only an optimization, so don't throw an error
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc);
|
|
156
|
+
Py_DECREF(newFunc);
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc);
|
|
160
|
+
}
|
|
161
|
+
#else
|
|
162
|
+
static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
|
|
163
|
+
if (PyMethod_Check(func)) {
|
|
164
|
+
func = PyMethod_GET_FUNCTION(func);
|
|
165
|
+
}
|
|
166
|
+
return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
|
|
167
|
+
}
|
|
168
|
+
#endif
|
|
169
|
+
|
|
170
|
+
static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) {
|
|
171
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
172
|
+
__Pyx_Py_XDECREF_SET(
|
|
173
|
+
__Pyx__CyFunction_GetClassObj(f),
|
|
174
|
+
((classobj) ? __Pyx_NewRef(classobj) : NULL));
|
|
175
|
+
#else
|
|
176
|
+
__Pyx_Py_XDECREF_SET(
|
|
177
|
+
// assigning to "mm_class", which is a "PyTypeObject*"
|
|
178
|
+
((PyCMethodObject *) (f))->mm_class,
|
|
179
|
+
(PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL));
|
|
180
|
+
#endif
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) {
|
|
184
|
+
__pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
|
|
185
|
+
|
|
186
|
+
m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type);
|
|
187
|
+
if (unlikely(!m->defaults))
|
|
188
|
+
return NULL;
|
|
189
|
+
return m->defaults;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
|
|
193
|
+
__pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
|
|
194
|
+
m->defaults_tuple = tuple;
|
|
195
|
+
Py_INCREF(tuple);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
|
|
199
|
+
__pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
|
|
200
|
+
m->defaults_kwdict = dict;
|
|
201
|
+
Py_INCREF(dict);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
|
|
205
|
+
__pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(func);
|
|
206
|
+
m->func_annotations = dict;
|
|
207
|
+
Py_INCREF(dict);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
//////////////////// CythonFunctionFromSharedModule /////////////////
|
|
211
|
+
//@requires: CythonFunctionPerModule
|
|
212
|
+
//@requires: CythonFunction
|
|
213
|
+
//@requires: CommonStructures.c::VerifyCachedType
|
|
214
|
+
//@substitute: naming
|
|
215
|
+
|
|
216
|
+
// Cutdown version that's only used when importing from shared utility code
|
|
217
|
+
static int __pyx_CyFunction_init(PyObject *module) {
|
|
218
|
+
$modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
|
|
219
|
+
|
|
220
|
+
PyTypeObject *tp = __Pyx_Get_CyFunction_Type();
|
|
221
|
+
if (!tp) return -1;
|
|
222
|
+
|
|
223
|
+
if (__Pyx_VerifyCachedType((PyObject*)tp,
|
|
224
|
+
__PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
|
|
225
|
+
__PYX_SHARED_SIZEOF(__pyx_CyFunctionObject)) != 0) {
|
|
226
|
+
Py_DECREF((PyObject*)tp);
|
|
227
|
+
return -1;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
mstate->__pyx_CyFunctionType = tp;
|
|
231
|
+
return 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
//////////////////// CythonFunctionShared.proto ////////////////////
|
|
235
|
+
//@requires: CythonFunctionPerModule
|
|
236
|
+
|
|
237
|
+
static PyObject *__Pyx_CyFunction_Init(PyObject *op_in, PyMethodDef *ml,
|
|
238
|
+
int flags, PyObject* qualname,
|
|
239
|
+
PyObject *closure,
|
|
240
|
+
PyObject *module, PyObject *globals,
|
|
241
|
+
PyObject* code);
|
|
242
|
+
|
|
243
|
+
#if CYTHON_VECTORCALL
|
|
244
|
+
static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
|
|
245
|
+
static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
|
|
246
|
+
static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
|
|
247
|
+
static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
|
|
248
|
+
#endif
|
|
249
|
+
|
|
250
|
+
//////////////////// CythonFunctionShared ////////////////////
|
|
251
|
+
//@requires: CommonStructures.c::FetchCommonType
|
|
252
|
+
//@requires: CommonStructures.c::CommonTypesMetaclass
|
|
253
|
+
//@requires: ObjectHandling.c::PyMethodNew
|
|
254
|
+
//@requires: ObjectHandling.c::PyVectorcallFastCallDict
|
|
255
|
+
//@requires: Exceptions.c::IgnoreException
|
|
256
|
+
//@requires: ModuleSetupCode.c::FastTypeChecks
|
|
257
|
+
//@requires: ModuleSetupCode.c::IncludeStructmemberH
|
|
258
|
+
//@requires: ObjectHandling.c::PyObjectGetAttrStr
|
|
259
|
+
//@requires: ObjectHandling.c::PyObjectCallOneArg
|
|
260
|
+
//@requires: ExtensionTypes.c::CallTypeTraverse
|
|
261
|
+
//@requires: Synchronization.c::CriticalSections
|
|
262
|
+
//@substitute: naming
|
|
263
|
+
|
|
264
|
+
static PyObject *
|
|
265
|
+
__Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op)
|
|
266
|
+
{
|
|
267
|
+
if (unlikely(op->func_doc == NULL)) {
|
|
268
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
269
|
+
const char *doc = op->func_methoddef->ml_doc;
|
|
270
|
+
#else
|
|
271
|
+
const char *doc = ((PyCFunctionObject*)op)->m_ml->ml_doc;
|
|
272
|
+
#endif
|
|
273
|
+
if (doc) {
|
|
274
|
+
op->func_doc = PyUnicode_FromString(doc);
|
|
275
|
+
if (unlikely(op->func_doc == NULL))
|
|
276
|
+
return NULL;
|
|
277
|
+
} else {
|
|
278
|
+
Py_INCREF(Py_None);
|
|
279
|
+
return Py_None;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
Py_INCREF(op->func_doc);
|
|
283
|
+
return op->func_doc;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
static PyObject *
|
|
287
|
+
__Pyx_CyFunction_get_doc(PyObject *op_in, void *closure) {
|
|
288
|
+
PyObject *result;
|
|
289
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
290
|
+
CYTHON_UNUSED_VAR(closure);
|
|
291
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
292
|
+
result = __Pyx_CyFunction_get_doc_locked(op);
|
|
293
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
static int
|
|
298
|
+
__Pyx_CyFunction_set_doc(PyObject *op_in, PyObject *value, void *context)
|
|
299
|
+
{
|
|
300
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
301
|
+
CYTHON_UNUSED_VAR(context);
|
|
302
|
+
if (value == NULL) {
|
|
303
|
+
// Mark as deleted
|
|
304
|
+
value = Py_None;
|
|
305
|
+
}
|
|
306
|
+
Py_INCREF(value);
|
|
307
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
308
|
+
__Pyx_Py_XDECREF_SET(op->func_doc, value);
|
|
309
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
310
|
+
return 0;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
static PyObject *
|
|
314
|
+
__Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op)
|
|
315
|
+
{
|
|
316
|
+
if (unlikely(op->func_name == NULL)) {
|
|
317
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
318
|
+
const char *name = op->func_methoddef->ml_name;
|
|
319
|
+
#else
|
|
320
|
+
const char *name = ((PyCFunctionObject*)op)->m_ml->ml_name;
|
|
321
|
+
#endif
|
|
322
|
+
op->func_name = PyUnicode_InternFromString(name);
|
|
323
|
+
if (unlikely(op->func_name == NULL))
|
|
324
|
+
return NULL;
|
|
325
|
+
}
|
|
326
|
+
Py_INCREF(op->func_name);
|
|
327
|
+
return op->func_name;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
static PyObject *
|
|
331
|
+
__Pyx_CyFunction_get_name(PyObject *op, void *context)
|
|
332
|
+
{
|
|
333
|
+
PyObject *result = NULL;
|
|
334
|
+
CYTHON_UNUSED_VAR(context);
|
|
335
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op);
|
|
336
|
+
result = __Pyx_CyFunction_get_name_locked(__Pyx_as_CyFunctionObject(op));
|
|
337
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
338
|
+
return result;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
static int
|
|
342
|
+
__Pyx_CyFunction_set_name(PyObject *op_in, PyObject *value, void *context)
|
|
343
|
+
{
|
|
344
|
+
CYTHON_UNUSED_VAR(context);
|
|
345
|
+
if (unlikely(value == NULL || !PyUnicode_Check(value))) {
|
|
346
|
+
PyErr_SetString(PyExc_TypeError,
|
|
347
|
+
"__name__ must be set to a string object");
|
|
348
|
+
return -1;
|
|
349
|
+
}
|
|
350
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
351
|
+
Py_INCREF(value);
|
|
352
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
353
|
+
__Pyx_Py_XDECREF_SET(op->func_name, value);
|
|
354
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
355
|
+
return 0;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
static PyObject *
|
|
359
|
+
__Pyx_CyFunction_get_qualname(PyObject *op_in, void *context)
|
|
360
|
+
{
|
|
361
|
+
CYTHON_UNUSED_VAR(context);
|
|
362
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
363
|
+
PyObject *result;
|
|
364
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
365
|
+
Py_INCREF(op->func_qualname);
|
|
366
|
+
result = op->func_qualname;
|
|
367
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
static int
|
|
372
|
+
__Pyx_CyFunction_set_qualname(PyObject *op_in, PyObject *value, void *context)
|
|
373
|
+
{
|
|
374
|
+
CYTHON_UNUSED_VAR(context);
|
|
375
|
+
if (unlikely(value == NULL || !PyUnicode_Check(value))) {
|
|
376
|
+
PyErr_SetString(PyExc_TypeError,
|
|
377
|
+
"__qualname__ must be set to a string object");
|
|
378
|
+
return -1;
|
|
379
|
+
}
|
|
380
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
381
|
+
Py_INCREF(value);
|
|
382
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
383
|
+
__Pyx_Py_XDECREF_SET(op->func_qualname, value);
|
|
384
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
385
|
+
return 0;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
|
|
389
|
+
static PyObject *
|
|
390
|
+
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context)
|
|
391
|
+
{
|
|
392
|
+
CYTHON_UNUSED_VAR(context);
|
|
393
|
+
// PyObject_GenericGetDict is not defined
|
|
394
|
+
if (unlikely(op->func_dict == NULL)) {
|
|
395
|
+
op->func_dict = PyDict_New();
|
|
396
|
+
if (unlikely(op->func_dict == NULL))
|
|
397
|
+
return NULL;
|
|
398
|
+
}
|
|
399
|
+
Py_INCREF(op->func_dict);
|
|
400
|
+
return op->func_dict;
|
|
401
|
+
}
|
|
402
|
+
#endif
|
|
403
|
+
|
|
404
|
+
static PyObject *
|
|
405
|
+
__Pyx_CyFunction_get_globals(PyObject *op_in, void *context)
|
|
406
|
+
{
|
|
407
|
+
CYTHON_UNUSED_VAR(context);
|
|
408
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
409
|
+
// Globals is read-only so no critical sections
|
|
410
|
+
Py_INCREF(op->func_globals);
|
|
411
|
+
return op->func_globals;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
static PyObject *
|
|
415
|
+
__Pyx_CyFunction_get_closure(PyObject *op, void *context)
|
|
416
|
+
{
|
|
417
|
+
CYTHON_UNUSED_VAR(op);
|
|
418
|
+
CYTHON_UNUSED_VAR(context);
|
|
419
|
+
Py_INCREF(Py_None);
|
|
420
|
+
return Py_None;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
static PyObject *
|
|
424
|
+
__Pyx_CyFunction_get_code(PyObject *op_in, void *context)
|
|
425
|
+
{
|
|
426
|
+
// code is read-only so no critical sections
|
|
427
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
428
|
+
PyObject* result = (op->func_code) ? op->func_code : Py_None;
|
|
429
|
+
CYTHON_UNUSED_VAR(context);
|
|
430
|
+
Py_INCREF(result);
|
|
431
|
+
return result;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
static int
|
|
435
|
+
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op, PyObject *op_obj) {
|
|
436
|
+
int result = 0;
|
|
437
|
+
PyObject *res = op->defaults_getter(op_obj);
|
|
438
|
+
if (unlikely(!res))
|
|
439
|
+
return -1;
|
|
440
|
+
|
|
441
|
+
// Cache result
|
|
442
|
+
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
|
|
443
|
+
op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
|
|
444
|
+
Py_INCREF(op->defaults_tuple);
|
|
445
|
+
op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
|
|
446
|
+
Py_INCREF(op->defaults_kwdict);
|
|
447
|
+
#else
|
|
448
|
+
op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0);
|
|
449
|
+
if (unlikely(!op->defaults_tuple)) result = -1;
|
|
450
|
+
else {
|
|
451
|
+
op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1);
|
|
452
|
+
if (unlikely(!op->defaults_kwdict)) result = -1;
|
|
453
|
+
}
|
|
454
|
+
#endif
|
|
455
|
+
Py_DECREF(res);
|
|
456
|
+
return result;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
static int
|
|
460
|
+
__Pyx_CyFunction_set_defaults(PyObject *op_in, PyObject* value, void *context) {
|
|
461
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
462
|
+
CYTHON_UNUSED_VAR(context);
|
|
463
|
+
if (!value) {
|
|
464
|
+
// del => explicit None to prevent rebuilding
|
|
465
|
+
value = Py_None;
|
|
466
|
+
} else if (unlikely(value != Py_None && !PyTuple_Check(value))) {
|
|
467
|
+
PyErr_SetString(PyExc_TypeError,
|
|
468
|
+
"__defaults__ must be set to a tuple object");
|
|
469
|
+
return -1;
|
|
470
|
+
}
|
|
471
|
+
PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not "
|
|
472
|
+
"currently affect the values used in function calls", 1);
|
|
473
|
+
Py_INCREF(value);
|
|
474
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
475
|
+
__Pyx_Py_XDECREF_SET(op->defaults_tuple, value);
|
|
476
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
477
|
+
return 0;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
static PyObject *
|
|
481
|
+
__Pyx_CyFunction_get_defaults_locked(PyObject *op_in) {
|
|
482
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
483
|
+
PyObject* result = op->defaults_tuple;
|
|
484
|
+
if (unlikely(!result)) {
|
|
485
|
+
if (op->defaults_getter) {
|
|
486
|
+
if (unlikely(__Pyx_CyFunction_init_defaults(op, op_in) < 0)) return NULL;
|
|
487
|
+
result = op->defaults_tuple;
|
|
488
|
+
} else {
|
|
489
|
+
result = Py_None;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
Py_INCREF(result);
|
|
493
|
+
return result;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
static PyObject *
|
|
497
|
+
__Pyx_CyFunction_get_defaults(PyObject *op, void *context) {
|
|
498
|
+
PyObject* result = NULL;
|
|
499
|
+
CYTHON_UNUSED_VAR(context);
|
|
500
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op);
|
|
501
|
+
result = __Pyx_CyFunction_get_defaults_locked(op);
|
|
502
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
503
|
+
return result;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
static int
|
|
507
|
+
__Pyx_CyFunction_set_kwdefaults(PyObject *op_in, PyObject* value, void *context) {
|
|
508
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
509
|
+
CYTHON_UNUSED_VAR(context);
|
|
510
|
+
if (!value) {
|
|
511
|
+
// del => explicit None to prevent rebuilding
|
|
512
|
+
value = Py_None;
|
|
513
|
+
} else if (unlikely(value != Py_None && !PyDict_Check(value))) {
|
|
514
|
+
PyErr_SetString(PyExc_TypeError,
|
|
515
|
+
"__kwdefaults__ must be set to a dict object");
|
|
516
|
+
return -1;
|
|
517
|
+
}
|
|
518
|
+
PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not "
|
|
519
|
+
"currently affect the values used in function calls", 1);
|
|
520
|
+
Py_INCREF(value);
|
|
521
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
522
|
+
__Pyx_Py_XDECREF_SET(op->defaults_kwdict, value);
|
|
523
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
524
|
+
return 0;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
static PyObject *
|
|
528
|
+
__Pyx_CyFunction_get_kwdefaults_locked(PyObject *op_in) {
|
|
529
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
530
|
+
PyObject* result = op->defaults_kwdict;
|
|
531
|
+
if (unlikely(!result)) {
|
|
532
|
+
if (op->defaults_getter) {
|
|
533
|
+
if (unlikely(__Pyx_CyFunction_init_defaults(op, op_in) < 0)) return NULL;
|
|
534
|
+
result = op->defaults_kwdict;
|
|
535
|
+
} else {
|
|
536
|
+
result = Py_None;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
Py_INCREF(result);
|
|
540
|
+
return result;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
static PyObject *
|
|
544
|
+
__Pyx_CyFunction_get_kwdefaults(PyObject *op, void *context) {
|
|
545
|
+
PyObject* result;
|
|
546
|
+
CYTHON_UNUSED_VAR(context);
|
|
547
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op);
|
|
548
|
+
result = __Pyx_CyFunction_get_kwdefaults_locked(op);
|
|
549
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
550
|
+
return result;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
static int __Pyx_CyFunction_set_annotate_in_dict_if_exists(PyObject *op_in, PyObject *value); /*proto*/
|
|
554
|
+
|
|
555
|
+
static int
|
|
556
|
+
__Pyx_CyFunction_set_annotations(PyObject *op_in, PyObject* value, void *context) {
|
|
557
|
+
CYTHON_UNUSED_VAR(context);
|
|
558
|
+
if (!value || value == Py_None) {
|
|
559
|
+
value = NULL;
|
|
560
|
+
} else if (unlikely(!PyDict_Check(value))) {
|
|
561
|
+
PyErr_SetString(PyExc_TypeError,
|
|
562
|
+
"__annotations__ must be set to a dict object");
|
|
563
|
+
return -1;
|
|
564
|
+
}
|
|
565
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
566
|
+
Py_XINCREF(value);
|
|
567
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
568
|
+
__Pyx_Py_XDECREF_SET(op->func_annotations, value);
|
|
569
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
570
|
+
if (unlikely(__Pyx_CyFunction_set_annotate_in_dict_if_exists(op_in, Py_None) < 0)) return -1;
|
|
571
|
+
return 0;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
static int
|
|
575
|
+
__Pyx_CyFunction_get_dict_if_exists(PyObject *op_in, PyObject **dict) {
|
|
576
|
+
/* Return 1 if the function dict exists, 0 otherwise. This cannot fail:
|
|
577
|
+
* _PyObject_GetDictPtr() may clear errors internally, but never reports them. */
|
|
578
|
+
#if CYTHON_COMPILING_IN_PYPY
|
|
579
|
+
*dict = PyObject_GenericGetDict(op_in, NULL);
|
|
580
|
+
#elif CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030C0000
|
|
581
|
+
*dict = __Pyx_as_CyFunctionObject(op_in)->func_dict;
|
|
582
|
+
#else
|
|
583
|
+
PyObject **dictptr = _PyObject_GetDictPtr(op_in);
|
|
584
|
+
*dict = likely(dictptr) ? *dictptr : NULL;
|
|
585
|
+
#endif
|
|
586
|
+
return *dict ? 1 : 0;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
static int
|
|
590
|
+
__Pyx_CyFunction_get_annotate_from_dict_if_exists(PyObject *op_in, PyObject **annotate) {
|
|
591
|
+
PyObject *dict;
|
|
592
|
+
int dict_found;
|
|
593
|
+
*annotate = NULL;
|
|
594
|
+
dict_found = __Pyx_CyFunction_get_dict_if_exists(op_in, &dict);
|
|
595
|
+
if (!dict_found) return 0;
|
|
596
|
+
return __Pyx_PyDict_GetItemRef(dict, PYIDENT("__annotate__"), annotate);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// if value==NULL, removes annotate from dict.
|
|
600
|
+
static int
|
|
601
|
+
__Pyx_CyFunction_set_annotate_in_dict_if_exists(PyObject *op_in, PyObject *value) {
|
|
602
|
+
PyObject *dict;
|
|
603
|
+
int dict_found;
|
|
604
|
+
dict_found = __Pyx_CyFunction_get_dict_if_exists(op_in, &dict);
|
|
605
|
+
if (!dict_found) return 0;
|
|
606
|
+
if (value) {
|
|
607
|
+
return PyDict_SetItem(dict, PYIDENT("__annotate__"), value);
|
|
608
|
+
} else {
|
|
609
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
|
|
610
|
+
return PyDict_Pop(dict, PYIDENT("__annotate__"), NULL);
|
|
611
|
+
#else
|
|
612
|
+
int result = PyDict_Contains(dict, PYIDENT("__annotate__"));
|
|
613
|
+
if (result == 1) {
|
|
614
|
+
result = PyDict_DelItem(dict, PYIDENT("__annotate__"));
|
|
615
|
+
}
|
|
616
|
+
return result;
|
|
617
|
+
#endif
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
static int
|
|
622
|
+
__Pyx_CyFunction_set_annotate_in_dict(PyObject *op_in, PyObject *value) {
|
|
623
|
+
PyObject *dict;
|
|
624
|
+
int result;
|
|
625
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
|
|
626
|
+
dict = __Pyx_CyFunction_get_dict(__Pyx_as_CyFunctionObject(op_in), NULL);
|
|
627
|
+
#else
|
|
628
|
+
dict = PyObject_GenericGetDict(op_in, NULL);
|
|
629
|
+
#endif
|
|
630
|
+
if (unlikely(!dict)) return -1;
|
|
631
|
+
result = PyDict_SetItem(dict, PYIDENT("__annotate__"), value);
|
|
632
|
+
Py_DECREF(dict);
|
|
633
|
+
return result;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
static PyObject *
|
|
637
|
+
__Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) {
|
|
638
|
+
PyObject* result = op->func_annotations;
|
|
639
|
+
if (unlikely(!result)) {
|
|
640
|
+
result = PyDict_New();
|
|
641
|
+
if (unlikely(!result)) return NULL;
|
|
642
|
+
op->func_annotations = result;
|
|
643
|
+
}
|
|
644
|
+
Py_INCREF(result);
|
|
645
|
+
return result;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
static PyObject *
|
|
649
|
+
__Pyx_CyFunction_get_annotations(PyObject *op_in, void *context) {
|
|
650
|
+
PyObject *annotate = NULL;
|
|
651
|
+
PyObject *result = NULL;
|
|
652
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
653
|
+
CYTHON_UNUSED_VAR(context);
|
|
654
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
655
|
+
result = __Pyx_XNewRef(op->func_annotations);
|
|
656
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
657
|
+
if (result) return result;
|
|
658
|
+
|
|
659
|
+
if (unlikely(__Pyx_CyFunction_get_annotate_from_dict_if_exists(op_in, &annotate) < 0)) return NULL;
|
|
660
|
+
if (!annotate || annotate == Py_None) {
|
|
661
|
+
Py_XDECREF(annotate);
|
|
662
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
663
|
+
result = __Pyx_CyFunction_get_annotations_locked(op);
|
|
664
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
665
|
+
return result;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
PyObject *format = PyLong_FromLong(1L); // annotationlib.Format.VALUE
|
|
669
|
+
if (likely(format)) {
|
|
670
|
+
if (!Py_EnterRecursiveCall(" cyfunction __annotations__.__get__")) {
|
|
671
|
+
result = __Pyx_PyObject_CallOneArg(annotate, format);
|
|
672
|
+
Py_LeaveRecursiveCall();
|
|
673
|
+
Py_DECREF(format);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
Py_DECREF(annotate);
|
|
677
|
+
if (unlikely(!result)) return NULL;
|
|
678
|
+
if (unlikely(!PyDict_Check(result))) {
|
|
679
|
+
PyErr_SetString(PyExc_TypeError, "__annotate__ must return a dict");
|
|
680
|
+
Py_DECREF(result);
|
|
681
|
+
return NULL;
|
|
682
|
+
}
|
|
683
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
684
|
+
__Pyx_Py_XDECREF_SET(op->func_annotations, __Pyx_NewRef(result));
|
|
685
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
686
|
+
return result;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
static PyObject *__Pyx_CyFunction_annotate_impl(PyObject *self, PyObject *arg) {
|
|
690
|
+
CYTHON_UNUSED_VAR(arg);
|
|
691
|
+
if (unlikely(!self)) {
|
|
692
|
+
PyErr_SetString(PyExc_SystemError, "cython __annotate__ called without 'self' argument");
|
|
693
|
+
return NULL;
|
|
694
|
+
}
|
|
695
|
+
// Although we guard against trivial recursive calls from self.__annotate__ = self.__annotate__
|
|
696
|
+
// we can't guard against all recursive calls.
|
|
697
|
+
PyObject *result;
|
|
698
|
+
if (Py_EnterRecursiveCall(" in cyfunction annotate")) {
|
|
699
|
+
return NULL;
|
|
700
|
+
}
|
|
701
|
+
result = __Pyx_CyFunction_get_annotations(self, NULL);
|
|
702
|
+
Py_LeaveRecursiveCall();
|
|
703
|
+
return result;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// We don't yet support PEP649 properly, so __annotate__ is
|
|
707
|
+
// implemented in a minimal way, just so that functools.wraps works.
|
|
708
|
+
static PyObject *
|
|
709
|
+
__Pyx_CyFunction_get_annotate(PyObject *op_in, void *context);
|
|
710
|
+
|
|
711
|
+
static int
|
|
712
|
+
__Pyx_CyFunction_set_annotate(PyObject *op_in, PyObject* value, void *context) {
|
|
713
|
+
CYTHON_UNUSED_VAR(context);
|
|
714
|
+
if (value == NULL) {
|
|
715
|
+
PyErr_SetString(PyExc_TypeError, "__annotate__ cannot be deleted");
|
|
716
|
+
return -1;
|
|
717
|
+
}
|
|
718
|
+
if (unlikely(value != Py_None && !PyCallable_Check(value))) {
|
|
719
|
+
PyErr_SetString(PyExc_TypeError, "__annotate__ must be callable or None");
|
|
720
|
+
return -1;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if (unlikely(__Pyx_TypeCheck(value, &PyCFunction_Type))) {
|
|
724
|
+
#if !CYTHON_ASSUME_SAFE_MACROS && !CYTHON_COMPILING_IN_PYPY
|
|
725
|
+
PyCFunction cfunction = PyCFunction_GetFunction(value);
|
|
726
|
+
if (unlikely(!cfunction)) return -1;
|
|
727
|
+
PyObject *value_self = PyCFunction_GetSelf(value);
|
|
728
|
+
if (unlikely(!value_self && PyErr_Occurred())) return -1;
|
|
729
|
+
#else
|
|
730
|
+
PyCFunction cfunction = PyCFunction_GET_FUNCTION(value);
|
|
731
|
+
PyObject *value_self = PyCFunction_GET_SELF(value);
|
|
732
|
+
#endif
|
|
733
|
+
if (cfunction == __Pyx_CyFunction_annotate_impl && value_self == op_in) {
|
|
734
|
+
// We're doing self.__annotate__ == self.__annotate__ somehow.
|
|
735
|
+
// Just clear it from the dictionary to avoid an infinite recursive call.
|
|
736
|
+
return __Pyx_CyFunction_set_annotate_in_dict_if_exists(op_in, NULL);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
if (value != Py_None) {
|
|
740
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
741
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
742
|
+
Py_CLEAR(op->func_annotations);
|
|
743
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
744
|
+
}
|
|
745
|
+
return __Pyx_CyFunction_set_annotate_in_dict(op_in, value);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030B0000
|
|
749
|
+
static PyObject *
|
|
750
|
+
__Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) {
|
|
751
|
+
int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE;
|
|
752
|
+
if (is_coroutine) {
|
|
753
|
+
PyObject *is_coroutine_value, *module, *fromlist, *marker = PYIDENT("_is_coroutine");
|
|
754
|
+
fromlist = PyList_New(1);
|
|
755
|
+
if (unlikely(!fromlist)) return NULL;
|
|
756
|
+
Py_INCREF(marker);
|
|
757
|
+
#if CYTHON_ASSUME_SAFE_MACROS
|
|
758
|
+
PyList_SET_ITEM(fromlist, 0, marker);
|
|
759
|
+
#else
|
|
760
|
+
if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) {
|
|
761
|
+
Py_DECREF(fromlist);
|
|
762
|
+
return NULL;
|
|
763
|
+
}
|
|
764
|
+
#endif
|
|
765
|
+
module = PyImport_ImportModuleLevelObject(PYIDENT("asyncio.coroutines"), NULL, NULL, fromlist, 0);
|
|
766
|
+
Py_DECREF(fromlist);
|
|
767
|
+
if (unlikely(!module)) {
|
|
768
|
+
goto ignore_or_error;
|
|
769
|
+
}
|
|
770
|
+
is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker);
|
|
771
|
+
Py_DECREF(module);
|
|
772
|
+
if (likely(is_coroutine_value)) {
|
|
773
|
+
return is_coroutine_value;
|
|
774
|
+
}
|
|
775
|
+
ignore_or_error:
|
|
776
|
+
if (!__Pyx_IgnoreException(PyExc_Exception)) {
|
|
777
|
+
return NULL;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
return __Pyx_PyBool_FromLong(is_coroutine);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
static PyObject *
|
|
785
|
+
__Pyx_CyFunction_get_is_coroutine(PyObject *op_in, void *context) {
|
|
786
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
787
|
+
PyObject *result;
|
|
788
|
+
CYTHON_UNUSED_VAR(context);
|
|
789
|
+
if (op->func_is_coroutine) {
|
|
790
|
+
return __Pyx_NewRef(op->func_is_coroutine);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
result = __Pyx_CyFunction_get_is_coroutine_value(op);
|
|
794
|
+
if (unlikely(!result))
|
|
795
|
+
return NULL;
|
|
796
|
+
|
|
797
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
798
|
+
// Guard against concurrent initialisation.
|
|
799
|
+
if (op->func_is_coroutine) {
|
|
800
|
+
Py_DECREF(result);
|
|
801
|
+
result = __Pyx_NewRef(op->func_is_coroutine);
|
|
802
|
+
} else {
|
|
803
|
+
op->func_is_coroutine = __Pyx_NewRef(result);
|
|
804
|
+
}
|
|
805
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
806
|
+
return result;
|
|
807
|
+
}
|
|
808
|
+
#endif
|
|
809
|
+
|
|
810
|
+
//static PyObject *
|
|
811
|
+
//__Pyx_CyFunction_get_signature(__pyx_CyFunctionObject *op, void *context) {
|
|
812
|
+
// PyObject *inspect_module, *signature_class, *signature;
|
|
813
|
+
// CYTHON_UNUSED_VAR(context);
|
|
814
|
+
// // from inspect import Signature
|
|
815
|
+
// inspect_module = PyImport_ImportModuleLevelObject(PYIDENT("inspect"), NULL, NULL, NULL, 0);
|
|
816
|
+
// if (unlikely(!inspect_module))
|
|
817
|
+
// goto bad;
|
|
818
|
+
// signature_class = __Pyx_PyObject_GetAttrStr(inspect_module, PYIDENT("Signature"));
|
|
819
|
+
// Py_DECREF(inspect_module);
|
|
820
|
+
// if (unlikely(!signature_class))
|
|
821
|
+
// goto bad;
|
|
822
|
+
// // return Signature.from_function(op)
|
|
823
|
+
// signature = PyObject_CallMethodObjArgs(signature_class, PYIDENT("from_function"), op, NULL);
|
|
824
|
+
// Py_DECREF(signature_class);
|
|
825
|
+
// if (likely(signature))
|
|
826
|
+
// return signature;
|
|
827
|
+
//bad:
|
|
828
|
+
// // make sure we raise an AttributeError from this property on any errors
|
|
829
|
+
// if (!PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
830
|
+
// PyErr_SetString(PyExc_AttributeError, "failed to calculate __signature__");
|
|
831
|
+
// return NULL;
|
|
832
|
+
//}
|
|
833
|
+
|
|
834
|
+
static void __Pyx_CyFunction_raise_argument_count_error(PyObject *func, const char* message, Py_ssize_t size) {
|
|
835
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
836
|
+
PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
|
|
837
|
+
if (!py_name) return;
|
|
838
|
+
PyErr_Format(PyExc_TypeError,
|
|
839
|
+
"%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
|
|
840
|
+
py_name, message, size);
|
|
841
|
+
Py_DECREF(py_name);
|
|
842
|
+
#else
|
|
843
|
+
const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
|
|
844
|
+
PyErr_Format(PyExc_TypeError,
|
|
845
|
+
"%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
|
|
846
|
+
name, message, size);
|
|
847
|
+
#endif
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
static void __Pyx_CyFunction_raise_type_error(PyObject *func, const char* message) {
|
|
851
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
852
|
+
PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
|
|
853
|
+
if (!py_name) return;
|
|
854
|
+
PyErr_Format(PyExc_TypeError,
|
|
855
|
+
"%.200S() %s",
|
|
856
|
+
py_name, message);
|
|
857
|
+
Py_DECREF(py_name);
|
|
858
|
+
#else
|
|
859
|
+
const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
|
|
860
|
+
PyErr_Format(PyExc_TypeError,
|
|
861
|
+
"%.200s() %s",
|
|
862
|
+
name, message);
|
|
863
|
+
#endif
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
867
|
+
// Note - for CyFunction alone it'd be easier to access this as a member
|
|
868
|
+
// rather than a getset. However, that's harder for fused functions
|
|
869
|
+
// where we have to override them again.
|
|
870
|
+
static PyObject *
|
|
871
|
+
__Pyx_CyFunction_get_module(PyObject *op_in, void *context) {
|
|
872
|
+
CYTHON_UNUSED_VAR(context);
|
|
873
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
874
|
+
Py_INCREF(op->func_module);
|
|
875
|
+
return op->func_module;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
static int
|
|
879
|
+
__Pyx_CyFunction_set_module(PyObject *op_in, PyObject* value, void *context) {
|
|
880
|
+
CYTHON_UNUSED_VAR(context);
|
|
881
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
882
|
+
if (value == NULL) {
|
|
883
|
+
value = Py_None;
|
|
884
|
+
}
|
|
885
|
+
Py_INCREF(value);
|
|
886
|
+
PyObject *old = op->func_module;
|
|
887
|
+
op->func_module = value;
|
|
888
|
+
Py_DECREF(old);
|
|
889
|
+
return 0;
|
|
890
|
+
}
|
|
891
|
+
#endif
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
static PyGetSetDef __pyx_CyFunction_getsets[] = {
|
|
895
|
+
{"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
|
|
896
|
+
{"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
|
|
897
|
+
{"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
|
|
898
|
+
{"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
|
|
899
|
+
{"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
|
|
900
|
+
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
|
|
901
|
+
{"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
|
|
902
|
+
{"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
|
|
903
|
+
#else
|
|
904
|
+
{"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
|
|
905
|
+
{"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
|
|
906
|
+
#endif
|
|
907
|
+
{"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
|
|
908
|
+
{"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
|
|
909
|
+
{"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
|
|
910
|
+
{"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
|
|
911
|
+
{"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
|
|
912
|
+
{"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
|
|
913
|
+
{"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
|
|
914
|
+
{"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
|
|
915
|
+
{"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
|
|
916
|
+
{"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
|
|
917
|
+
{"__annotate__", (getter)__Pyx_CyFunction_get_annotate, (setter)__Pyx_CyFunction_set_annotate, 0, 0},
|
|
918
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030B0000
|
|
919
|
+
{"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0},
|
|
920
|
+
#endif
|
|
921
|
+
// {"__signature__", (getter)__Pyx_CyFunction_get_signature, 0, 0, 0},
|
|
922
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
923
|
+
{"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
|
|
924
|
+
#endif
|
|
925
|
+
{0, 0, 0, 0, 0}
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
static PyMemberDef __pyx_CyFunction_members[] = {
|
|
929
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
930
|
+
{"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
|
|
931
|
+
#endif
|
|
932
|
+
#if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
|
|
933
|
+
{"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict),
|
|
934
|
+
__PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
|
|
935
|
+
#endif
|
|
936
|
+
#if CYTHON_VECTORCALL
|
|
937
|
+
#if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
|
|
938
|
+
{"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall),
|
|
939
|
+
__PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
|
|
940
|
+
#else
|
|
941
|
+
{"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0},
|
|
942
|
+
#endif
|
|
943
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
944
|
+
{"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist),
|
|
945
|
+
__PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
|
|
946
|
+
#else
|
|
947
|
+
{"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0},
|
|
948
|
+
#endif
|
|
949
|
+
#endif
|
|
950
|
+
{0, 0, 0, 0, 0}
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
static PyObject *
|
|
954
|
+
__Pyx_CyFunction_reduce(PyObject *m_in, PyObject *args)
|
|
955
|
+
{
|
|
956
|
+
PyObject *result = NULL;
|
|
957
|
+
__pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(m_in);
|
|
958
|
+
CYTHON_UNUSED_VAR(args);
|
|
959
|
+
__Pyx_BEGIN_CRITICAL_SECTION(m_in);
|
|
960
|
+
Py_INCREF(m->func_qualname);
|
|
961
|
+
result = m->func_qualname;
|
|
962
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
963
|
+
return result;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
static PyMethodDef __pyx_CyFunction_methods[] = {
|
|
967
|
+
// Having __annotate_cython__ as an attribute makes it pickleable.
|
|
968
|
+
// Keep it as the first element to make access easier.
|
|
969
|
+
{"__annotate_cython__", __Pyx_CyFunction_annotate_impl, METH_O,
|
|
970
|
+
"Placeholder __annotate__ function to allow 'functools.wraps' to work "
|
|
971
|
+
"on Cython functions."},
|
|
972
|
+
{"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_NOARGS, 0},
|
|
973
|
+
{0, 0, 0, 0}
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
// We don't yet support PEP649 properly, so __annotate__ is
|
|
977
|
+
// implemented in a minimal way, just so that functools.wraps works.
|
|
978
|
+
static PyObject *
|
|
979
|
+
__Pyx_CyFunction_get_annotate(PyObject *op_in, void *context) {
|
|
980
|
+
PyObject *annotate = NULL;
|
|
981
|
+
CYTHON_UNUSED_VAR(context);
|
|
982
|
+
if (unlikely(__Pyx_CyFunction_get_annotate_from_dict_if_exists(op_in, &annotate) < 0)) return NULL;
|
|
983
|
+
if (annotate) return annotate;
|
|
984
|
+
|
|
985
|
+
PyObject *method = PyCFunction_New(
|
|
986
|
+
&__pyx_CyFunction_methods[0],
|
|
987
|
+
op_in);
|
|
988
|
+
return method;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
994
|
+
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
|
|
995
|
+
#else
|
|
996
|
+
#define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist)
|
|
997
|
+
#endif
|
|
998
|
+
|
|
999
|
+
static PyObject *__Pyx_CyFunction_Init(PyObject *op_in,
|
|
1000
|
+
PyMethodDef *ml, int flags, PyObject* qualname,
|
|
1001
|
+
PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
|
|
1002
|
+
__pyx_CyFunctionObject* op = __Pyx_as_CyFunctionObject(op_in);
|
|
1003
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
1004
|
+
PyCFunctionObject *cf = (PyCFunctionObject*) op;
|
|
1005
|
+
#endif
|
|
1006
|
+
if (unlikely(op == NULL))
|
|
1007
|
+
return NULL;
|
|
1008
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1009
|
+
op->func_methoddef = ml;
|
|
1010
|
+
Py_INCREF(module);
|
|
1011
|
+
op->func_module = module;
|
|
1012
|
+
#endif
|
|
1013
|
+
op->flags = flags;
|
|
1014
|
+
__Pyx_CyFunction_weakreflist(op) = NULL;
|
|
1015
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
1016
|
+
cf->m_ml = ml;
|
|
1017
|
+
// This is set for the benefit of __Pyx_CyOrPyCFunction_GET_SELF. It is never reassigned, so
|
|
1018
|
+
// when we know an object is a CyFunction we don't even need to look it up.__Pyx_CyFunction_set_module
|
|
1019
|
+
cf->m_self = (PyObject *) op;
|
|
1020
|
+
#endif
|
|
1021
|
+
Py_XINCREF(closure);
|
|
1022
|
+
op->func_closure = closure;
|
|
1023
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
1024
|
+
Py_XINCREF(module);
|
|
1025
|
+
cf->m_module = module;
|
|
1026
|
+
#endif
|
|
1027
|
+
#if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
|
|
1028
|
+
op->func_dict = NULL;
|
|
1029
|
+
#endif
|
|
1030
|
+
op->func_name = NULL;
|
|
1031
|
+
Py_INCREF(qualname);
|
|
1032
|
+
op->func_qualname = qualname;
|
|
1033
|
+
op->func_doc = NULL;
|
|
1034
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1035
|
+
op->func_classobj = NULL;
|
|
1036
|
+
#else
|
|
1037
|
+
((PyCMethodObject*)op)->mm_class = NULL;
|
|
1038
|
+
#endif
|
|
1039
|
+
op->func_globals = globals;
|
|
1040
|
+
Py_INCREF(op->func_globals);
|
|
1041
|
+
Py_XINCREF(code);
|
|
1042
|
+
op->func_code = code;
|
|
1043
|
+
// Dynamic Default args
|
|
1044
|
+
op->defaults = NULL;
|
|
1045
|
+
op->defaults_tuple = NULL;
|
|
1046
|
+
op->defaults_kwdict = NULL;
|
|
1047
|
+
op->defaults_getter = NULL;
|
|
1048
|
+
op->func_annotations = NULL;
|
|
1049
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030B0000
|
|
1050
|
+
op->func_is_coroutine = NULL;
|
|
1051
|
+
#endif
|
|
1052
|
+
#if CYTHON_VECTORCALL
|
|
1053
|
+
switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) {
|
|
1054
|
+
case METH_NOARGS:
|
|
1055
|
+
__Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS;
|
|
1056
|
+
break;
|
|
1057
|
+
case METH_O:
|
|
1058
|
+
__Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O;
|
|
1059
|
+
break;
|
|
1060
|
+
// case METH_FASTCALL is not used
|
|
1061
|
+
case METH_METHOD | METH_FASTCALL | METH_KEYWORDS:
|
|
1062
|
+
__Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD;
|
|
1063
|
+
break;
|
|
1064
|
+
case METH_FASTCALL | METH_KEYWORDS:
|
|
1065
|
+
__Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS;
|
|
1066
|
+
break;
|
|
1067
|
+
// case METH_VARARGS is not used
|
|
1068
|
+
case METH_VARARGS | METH_KEYWORDS:
|
|
1069
|
+
__Pyx_CyFunction_func_vectorcall(op) = NULL;
|
|
1070
|
+
break;
|
|
1071
|
+
default:
|
|
1072
|
+
PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
|
|
1073
|
+
Py_DECREF(op_in);
|
|
1074
|
+
return NULL;
|
|
1075
|
+
}
|
|
1076
|
+
#endif
|
|
1077
|
+
return op_in;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
static int __Pyx__CyFunction_clear(__pyx_CyFunctionObject *m)
|
|
1081
|
+
{
|
|
1082
|
+
Py_CLEAR(m->func_closure);
|
|
1083
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1084
|
+
Py_CLEAR(m->func_module);
|
|
1085
|
+
#else
|
|
1086
|
+
Py_CLEAR(((PyCFunctionObject*)m)->m_module);
|
|
1087
|
+
#endif
|
|
1088
|
+
#if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
|
|
1089
|
+
Py_CLEAR(m->func_dict);
|
|
1090
|
+
#elif PY_VERSION_HEX < 0x030d0000
|
|
1091
|
+
_PyObject_ClearManagedDict((PyObject*)m);
|
|
1092
|
+
#else
|
|
1093
|
+
PyObject_ClearManagedDict((PyObject*)m);
|
|
1094
|
+
#endif
|
|
1095
|
+
Py_CLEAR(m->func_name);
|
|
1096
|
+
Py_CLEAR(m->func_qualname);
|
|
1097
|
+
Py_CLEAR(m->func_doc);
|
|
1098
|
+
Py_CLEAR(m->func_globals);
|
|
1099
|
+
Py_CLEAR(m->func_code);
|
|
1100
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1101
|
+
Py_CLEAR(m->func_classobj);
|
|
1102
|
+
#else
|
|
1103
|
+
{
|
|
1104
|
+
PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class;
|
|
1105
|
+
((PyCMethodObject *) (m))->mm_class = NULL;
|
|
1106
|
+
Py_XDECREF(cls);
|
|
1107
|
+
}
|
|
1108
|
+
#endif
|
|
1109
|
+
Py_CLEAR(m->defaults_tuple);
|
|
1110
|
+
Py_CLEAR(m->defaults_kwdict);
|
|
1111
|
+
Py_CLEAR(m->func_annotations);
|
|
1112
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030B0000
|
|
1113
|
+
Py_CLEAR(m->func_is_coroutine);
|
|
1114
|
+
#endif
|
|
1115
|
+
|
|
1116
|
+
Py_CLEAR(m->defaults);
|
|
1117
|
+
|
|
1118
|
+
return 0;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
static int
|
|
1122
|
+
__Pyx_CyFunction_clear(PyObject *m)
|
|
1123
|
+
{
|
|
1124
|
+
return __Pyx__CyFunction_clear(__Pyx_as_CyFunctionObject(m));
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
static void __Pyx__CyFunction_dealloc(PyObject *m)
|
|
1128
|
+
{
|
|
1129
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(m);
|
|
1130
|
+
if (__Pyx_CyFunction_weakreflist(cyfunc) != NULL)
|
|
1131
|
+
PyObject_ClearWeakRefs(m);
|
|
1132
|
+
__Pyx__CyFunction_clear(cyfunc);
|
|
1133
|
+
__Pyx_PyHeapTypeObject_GC_Del(m);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
static void __Pyx_CyFunction_dealloc(PyObject *m)
|
|
1137
|
+
{
|
|
1138
|
+
PyObject_GC_UnTrack(m);
|
|
1139
|
+
__Pyx__CyFunction_dealloc(m);
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
static int __Pyx_CyFunction_traverse(PyObject *m_in, visitproc visit, void *arg)
|
|
1143
|
+
{
|
|
1144
|
+
__pyx_CyFunctionObject *m = __Pyx_as_CyFunctionObject(m_in);
|
|
1145
|
+
{
|
|
1146
|
+
int e = __Pyx_call_type_traverse(m_in, 1, visit, arg);
|
|
1147
|
+
if (e) return e;
|
|
1148
|
+
}
|
|
1149
|
+
Py_VISIT(m->func_closure);
|
|
1150
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1151
|
+
Py_VISIT(m->func_module);
|
|
1152
|
+
#else
|
|
1153
|
+
Py_VISIT(((PyCFunctionObject*)m)->m_module);
|
|
1154
|
+
#endif
|
|
1155
|
+
#if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
|
|
1156
|
+
Py_VISIT(m->func_dict);
|
|
1157
|
+
#else
|
|
1158
|
+
{
|
|
1159
|
+
int e =
|
|
1160
|
+
#if PY_VERSION_HEX < 0x030d0000
|
|
1161
|
+
_PyObject_VisitManagedDict
|
|
1162
|
+
#else
|
|
1163
|
+
PyObject_VisitManagedDict
|
|
1164
|
+
#endif
|
|
1165
|
+
((PyObject*)m, visit, arg);
|
|
1166
|
+
if (e != 0) return e;
|
|
1167
|
+
}
|
|
1168
|
+
#endif
|
|
1169
|
+
__Pyx_VISIT_CONST(m->func_name);
|
|
1170
|
+
__Pyx_VISIT_CONST(m->func_qualname);
|
|
1171
|
+
Py_VISIT(m->func_doc);
|
|
1172
|
+
Py_VISIT(m->func_globals);
|
|
1173
|
+
// The code objects that we generate only contain plain constants and can never participate in reference cycles.
|
|
1174
|
+
__Pyx_VISIT_CONST(m->func_code);
|
|
1175
|
+
Py_VISIT(__Pyx__CyFunction_GetClassObj(m));
|
|
1176
|
+
Py_VISIT(m->defaults_tuple);
|
|
1177
|
+
Py_VISIT(m->defaults_kwdict);
|
|
1178
|
+
Py_VISIT(m->func_annotations);
|
|
1179
|
+
#if __PYX_LIMITED_VERSION_HEX < 0x030B0000
|
|
1180
|
+
Py_VISIT(m->func_is_coroutine);
|
|
1181
|
+
#endif
|
|
1182
|
+
Py_VISIT(m->defaults);
|
|
1183
|
+
|
|
1184
|
+
return 0;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
static PyObject*
|
|
1188
|
+
__Pyx_CyFunction_repr(PyObject *op_in)
|
|
1189
|
+
{
|
|
1190
|
+
__pyx_CyFunctionObject *op = __Pyx_as_CyFunctionObject(op_in);
|
|
1191
|
+
PyObject *repr;
|
|
1192
|
+
__Pyx_BEGIN_CRITICAL_SECTION(op_in);
|
|
1193
|
+
repr = PyUnicode_FromFormat("<cyfunction %U at %p>",
|
|
1194
|
+
op->func_qualname, (void *)op);
|
|
1195
|
+
__Pyx_END_CRITICAL_SECTION();
|
|
1196
|
+
return repr;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
|
|
1200
|
+
// originally copied from PyCFunction_Call() in CPython's Objects/methodobject.c
|
|
1201
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1202
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
|
|
1203
|
+
PyCFunction meth = cyfunc->func_methoddef->ml_meth;
|
|
1204
|
+
int flags = cyfunc->func_methoddef->ml_flags;
|
|
1205
|
+
#else
|
|
1206
|
+
PyCFunctionObject* f = (PyCFunctionObject*)func;
|
|
1207
|
+
PyCFunction meth = f->m_ml->ml_meth;
|
|
1208
|
+
int flags = f->m_ml->ml_flags;
|
|
1209
|
+
#endif
|
|
1210
|
+
Py_ssize_t size;
|
|
1211
|
+
|
|
1212
|
+
switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
|
|
1213
|
+
case METH_VARARGS:
|
|
1214
|
+
if (likely(kw == NULL || PyDict_Size(kw) == 0))
|
|
1215
|
+
return (*meth)(self, arg);
|
|
1216
|
+
break;
|
|
1217
|
+
case METH_VARARGS | METH_KEYWORDS:
|
|
1218
|
+
return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw);
|
|
1219
|
+
case METH_NOARGS:
|
|
1220
|
+
if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
|
|
1221
|
+
#if CYTHON_ASSUME_SAFE_SIZE
|
|
1222
|
+
size = PyTuple_GET_SIZE(arg);
|
|
1223
|
+
#else
|
|
1224
|
+
size = PyTuple_Size(arg);
|
|
1225
|
+
if (unlikely(size < 0)) return NULL;
|
|
1226
|
+
#endif
|
|
1227
|
+
if (likely(size == 0))
|
|
1228
|
+
return (*meth)(self, NULL);
|
|
1229
|
+
__Pyx_CyFunction_raise_argument_count_error(
|
|
1230
|
+
func,
|
|
1231
|
+
"takes no arguments", size);
|
|
1232
|
+
return NULL;
|
|
1233
|
+
}
|
|
1234
|
+
break;
|
|
1235
|
+
case METH_O:
|
|
1236
|
+
if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
|
|
1237
|
+
#if CYTHON_ASSUME_SAFE_SIZE
|
|
1238
|
+
size = PyTuple_GET_SIZE(arg);
|
|
1239
|
+
#else
|
|
1240
|
+
size = PyTuple_Size(arg);
|
|
1241
|
+
if (unlikely(size < 0)) return NULL;
|
|
1242
|
+
#endif
|
|
1243
|
+
if (likely(size == 1)) {
|
|
1244
|
+
PyObject *result, *arg0;
|
|
1245
|
+
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
|
|
1246
|
+
arg0 = PyTuple_GET_ITEM(arg, 0);
|
|
1247
|
+
#else
|
|
1248
|
+
arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
|
|
1249
|
+
#endif
|
|
1250
|
+
result = (*meth)(self, arg0);
|
|
1251
|
+
#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
|
|
1252
|
+
Py_DECREF(arg0);
|
|
1253
|
+
#endif
|
|
1254
|
+
return result;
|
|
1255
|
+
}
|
|
1256
|
+
__Pyx_CyFunction_raise_argument_count_error(
|
|
1257
|
+
func,
|
|
1258
|
+
"takes exactly one argument", size);
|
|
1259
|
+
return NULL;
|
|
1260
|
+
}
|
|
1261
|
+
break;
|
|
1262
|
+
default:
|
|
1263
|
+
PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
|
|
1264
|
+
return NULL;
|
|
1265
|
+
}
|
|
1266
|
+
__Pyx_CyFunction_raise_type_error(
|
|
1267
|
+
func, "takes no keyword arguments");
|
|
1268
|
+
return NULL;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
|
|
1272
|
+
PyObject *result;
|
|
1273
|
+
result = __Pyx_CyFunction_CallMethod(func, func, arg, kw);
|
|
1274
|
+
return result;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
|
|
1278
|
+
PyObject *result;
|
|
1279
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
|
|
1280
|
+
|
|
1281
|
+
#if CYTHON_VECTORCALL
|
|
1282
|
+
// Prefer vectorcall if available. This is not the typical case, as
|
|
1283
|
+
// CPython would normally use vectorcall directly instead of tp_call.
|
|
1284
|
+
__pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
|
|
1285
|
+
if (vc) {
|
|
1286
|
+
#if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
|
|
1287
|
+
return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
|
|
1288
|
+
#else
|
|
1289
|
+
// avoid unused function warning
|
|
1290
|
+
(void) &__Pyx_PyVectorcall_FastCallDict;
|
|
1291
|
+
return PyVectorcall_Call(func, args, kw);
|
|
1292
|
+
#endif
|
|
1293
|
+
}
|
|
1294
|
+
#endif
|
|
1295
|
+
|
|
1296
|
+
if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
|
|
1297
|
+
Py_ssize_t argc;
|
|
1298
|
+
PyObject *new_args;
|
|
1299
|
+
PyObject *self;
|
|
1300
|
+
|
|
1301
|
+
#if CYTHON_ASSUME_SAFE_SIZE
|
|
1302
|
+
argc = PyTuple_GET_SIZE(args);
|
|
1303
|
+
#else
|
|
1304
|
+
argc = PyTuple_Size(args);
|
|
1305
|
+
if (unlikely(argc < 0)) return NULL;
|
|
1306
|
+
#endif
|
|
1307
|
+
new_args = PyTuple_GetSlice(args, 1, argc);
|
|
1308
|
+
|
|
1309
|
+
if (unlikely(!new_args))
|
|
1310
|
+
return NULL;
|
|
1311
|
+
|
|
1312
|
+
self = PyTuple_GetItem(args, 0);
|
|
1313
|
+
if (unlikely(!self)) {
|
|
1314
|
+
Py_DECREF(new_args);
|
|
1315
|
+
PyErr_Format(PyExc_TypeError,
|
|
1316
|
+
"unbound method %.200S() needs an argument",
|
|
1317
|
+
cyfunc->func_qualname);
|
|
1318
|
+
return NULL;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
|
|
1322
|
+
Py_DECREF(new_args);
|
|
1323
|
+
} else {
|
|
1324
|
+
result = __Pyx_CyFunction_Call(func, args, kw);
|
|
1325
|
+
}
|
|
1326
|
+
return result;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
#if CYTHON_VECTORCALL
|
|
1330
|
+
// Check that kwnames is empty (if you want to allow keyword arguments,
|
|
1331
|
+
// simply pass kwnames=NULL) and figure out what to do with "self".
|
|
1332
|
+
// Return value:
|
|
1333
|
+
// 1: self = args[0]
|
|
1334
|
+
// 0: self = cyfunc->func.m_self
|
|
1335
|
+
// -1: error
|
|
1336
|
+
static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(PyObject *func, __pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
|
|
1337
|
+
{
|
|
1338
|
+
int ret = 0;
|
|
1339
|
+
if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
|
|
1340
|
+
if (unlikely(nargs < 1)) {
|
|
1341
|
+
__Pyx_CyFunction_raise_type_error(
|
|
1342
|
+
func, "needs an argument");
|
|
1343
|
+
return -1;
|
|
1344
|
+
}
|
|
1345
|
+
ret = 1;
|
|
1346
|
+
}
|
|
1347
|
+
if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) {
|
|
1348
|
+
__Pyx_CyFunction_raise_type_error(
|
|
1349
|
+
func, "takes no keyword arguments");
|
|
1350
|
+
return -1;
|
|
1351
|
+
}
|
|
1352
|
+
return ret;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
|
1356
|
+
{
|
|
1357
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
|
|
1358
|
+
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
|
1359
|
+
PyObject *self;
|
|
1360
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1361
|
+
PyCFunction meth = cyfunc->func_methoddef->ml_meth;
|
|
1362
|
+
if (unlikely(!meth)) return NULL;
|
|
1363
|
+
#else
|
|
1364
|
+
PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
|
|
1365
|
+
#endif
|
|
1366
|
+
|
|
1367
|
+
switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, kwnames)) {
|
|
1368
|
+
case 1:
|
|
1369
|
+
self = args[0];
|
|
1370
|
+
args += 1;
|
|
1371
|
+
nargs -= 1;
|
|
1372
|
+
break;
|
|
1373
|
+
case 0:
|
|
1374
|
+
self = func;
|
|
1375
|
+
break;
|
|
1376
|
+
default:
|
|
1377
|
+
return NULL;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
if (unlikely(nargs != 0)) {
|
|
1381
|
+
__Pyx_CyFunction_raise_argument_count_error(
|
|
1382
|
+
func, "takes no arguments", nargs);
|
|
1383
|
+
return NULL;
|
|
1384
|
+
}
|
|
1385
|
+
return meth(self, NULL);
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
|
1389
|
+
{
|
|
1390
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
|
|
1391
|
+
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
|
1392
|
+
PyObject *self;
|
|
1393
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1394
|
+
PyCFunction meth = cyfunc->func_methoddef->ml_meth;
|
|
1395
|
+
if (unlikely(!meth)) return NULL;
|
|
1396
|
+
#else
|
|
1397
|
+
PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
|
|
1398
|
+
#endif
|
|
1399
|
+
|
|
1400
|
+
switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, kwnames)) {
|
|
1401
|
+
case 1:
|
|
1402
|
+
self = args[0];
|
|
1403
|
+
args += 1;
|
|
1404
|
+
nargs -= 1;
|
|
1405
|
+
break;
|
|
1406
|
+
case 0:
|
|
1407
|
+
self = func;
|
|
1408
|
+
break;
|
|
1409
|
+
default:
|
|
1410
|
+
return NULL;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
if (unlikely(nargs != 1)) {
|
|
1414
|
+
__Pyx_CyFunction_raise_argument_count_error(
|
|
1415
|
+
func, "takes exactly one argument", nargs);
|
|
1416
|
+
return NULL;
|
|
1417
|
+
}
|
|
1418
|
+
return meth(self, args[0]);
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
|
1422
|
+
{
|
|
1423
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
|
|
1424
|
+
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
|
1425
|
+
PyObject *self;
|
|
1426
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1427
|
+
PyCFunction meth = cyfunc->func_methoddef->ml_meth;
|
|
1428
|
+
if (unlikely(!meth)) return NULL;
|
|
1429
|
+
#else
|
|
1430
|
+
PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
|
|
1431
|
+
#endif
|
|
1432
|
+
|
|
1433
|
+
switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, NULL)) {
|
|
1434
|
+
case 1:
|
|
1435
|
+
self = args[0];
|
|
1436
|
+
args += 1;
|
|
1437
|
+
nargs -= 1;
|
|
1438
|
+
break;
|
|
1439
|
+
case 0:
|
|
1440
|
+
self = func;
|
|
1441
|
+
break;
|
|
1442
|
+
default:
|
|
1443
|
+
return NULL;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames);
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
|
1450
|
+
{
|
|
1451
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
|
|
1452
|
+
PyTypeObject *cls = (PyTypeObject *) __Pyx__CyFunction_GetClassObj(cyfunc);
|
|
1453
|
+
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
|
1454
|
+
PyObject *self;
|
|
1455
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1456
|
+
PyCFunction meth = cyfunc->func_methoddef->ml_meth;
|
|
1457
|
+
if (unlikely(!meth)) return NULL;
|
|
1458
|
+
#else
|
|
1459
|
+
PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
|
|
1460
|
+
#endif
|
|
1461
|
+
switch (__Pyx_CyFunction_Vectorcall_CheckArgs(func, cyfunc, nargs, NULL)) {
|
|
1462
|
+
case 1:
|
|
1463
|
+
self = args[0];
|
|
1464
|
+
args += 1;
|
|
1465
|
+
nargs -= 1;
|
|
1466
|
+
break;
|
|
1467
|
+
case 0:
|
|
1468
|
+
self = func;
|
|
1469
|
+
break;
|
|
1470
|
+
default:
|
|
1471
|
+
return NULL;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
#if PY_VERSION_HEX < 0x030e00A6
|
|
1475
|
+
// See https://github.com/python/cpython/pull/131135
|
|
1476
|
+
size_t nargs_value = (size_t) nargs;
|
|
1477
|
+
#else
|
|
1478
|
+
Py_ssize_t nargs_value = nargs;
|
|
1479
|
+
#endif
|
|
1480
|
+
|
|
1481
|
+
return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames);
|
|
1482
|
+
}
|
|
1483
|
+
#endif
|
|
1484
|
+
|
|
1485
|
+
static PyType_Slot __pyx_CyFunctionType_slots[] = {
|
|
1486
|
+
{Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc},
|
|
1487
|
+
{Py_tp_repr, (void *)__Pyx_CyFunction_repr},
|
|
1488
|
+
{Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod},
|
|
1489
|
+
{Py_tp_traverse, (void *)__Pyx_CyFunction_traverse},
|
|
1490
|
+
{Py_tp_clear, (void *)__Pyx_CyFunction_clear},
|
|
1491
|
+
{Py_tp_methods, (void *)__pyx_CyFunction_methods},
|
|
1492
|
+
{Py_tp_members, (void *)__pyx_CyFunction_members},
|
|
1493
|
+
{Py_tp_getset, (void *)__pyx_CyFunction_getsets},
|
|
1494
|
+
{Py_tp_descr_get, (void *)__Pyx_PyMethod_New},
|
|
1495
|
+
{0, 0},
|
|
1496
|
+
};
|
|
1497
|
+
|
|
1498
|
+
static PyType_Spec __pyx_CyFunctionType_spec = {
|
|
1499
|
+
__PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
|
|
1500
|
+
__PYX_SHARED_SIZEOF(__pyx_CyFunctionObject),
|
|
1501
|
+
0,
|
|
1502
|
+
#ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
|
|
1503
|
+
Py_TPFLAGS_METHOD_DESCRIPTOR |
|
|
1504
|
+
#endif
|
|
1505
|
+
#if CYTHON_VECTORCALL
|
|
1506
|
+
#if defined(Py_TPFLAGS_HAVE_VECTORCALL)
|
|
1507
|
+
Py_TPFLAGS_HAVE_VECTORCALL |
|
|
1508
|
+
#elif defined(_Py_TPFLAGS_HAVE_VECTORCALL)
|
|
1509
|
+
_Py_TPFLAGS_HAVE_VECTORCALL |
|
|
1510
|
+
#endif
|
|
1511
|
+
#endif // CYTHON_VECTORCALL
|
|
1512
|
+
#if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
1513
|
+
Py_TPFLAGS_MANAGED_DICT |
|
|
1514
|
+
#endif
|
|
1515
|
+
Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
|
|
1516
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
|
1517
|
+
__pyx_CyFunctionType_slots
|
|
1518
|
+
};
|
|
1519
|
+
|
|
1520
|
+
static int __pyx_CyFunction_init(PyObject *module) {
|
|
1521
|
+
$modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
|
|
1522
|
+
mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(
|
|
1523
|
+
mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL);
|
|
1524
|
+
if (unlikely(mstate->__pyx_CyFunctionType == NULL)) {
|
|
1525
|
+
return -1;
|
|
1526
|
+
}
|
|
1527
|
+
return 0;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
//////////////////// CythonFunction.export ////////////////////
|
|
1531
|
+
|
|
1532
|
+
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
|
|
1533
|
+
int flags, PyObject* qualname,
|
|
1534
|
+
PyObject *closure,
|
|
1535
|
+
PyObject *module, PyObject *globals,
|
|
1536
|
+
PyObject* code);
|
|
1537
|
+
|
|
1538
|
+
static PyTypeObject *__Pyx_Get_CyFunction_Type(void);
|
|
1539
|
+
|
|
1540
|
+
//////////////////// CythonFunction ////////////////////
|
|
1541
|
+
//@requires: CythonFunctionShared
|
|
1542
|
+
|
|
1543
|
+
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
|
|
1544
|
+
PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
|
|
1545
|
+
// Only used when using shared utility module
|
|
1546
|
+
(void)&__Pyx_Get_CyFunction_Type;
|
|
1547
|
+
|
|
1548
|
+
PyObject *op = __Pyx_CyFunction_Init(
|
|
1549
|
+
PyObject_GC_New(PyObject, CGLOBAL(__pyx_CyFunctionType)),
|
|
1550
|
+
ml, flags, qualname, closure, module, globals, code
|
|
1551
|
+
);
|
|
1552
|
+
if (likely(op)) {
|
|
1553
|
+
PyObject_GC_Track(op);
|
|
1554
|
+
}
|
|
1555
|
+
return op;
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
static PyTypeObject *__Pyx_Get_CyFunction_Type(void) {
|
|
1559
|
+
PyTypeObject *tp = CGLOBAL(__pyx_CyFunctionType);
|
|
1560
|
+
Py_INCREF((PyObject*)tp);
|
|
1561
|
+
return tp;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
//////////////////// CyFunctionClassCell.proto ////////////////////
|
|
1565
|
+
static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj);/*proto*/
|
|
1566
|
+
|
|
1567
|
+
//////////////////// CyFunctionClassCell ////////////////////
|
|
1568
|
+
//@requires: CythonFunctionPerModule
|
|
1569
|
+
|
|
1570
|
+
static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj) {
|
|
1571
|
+
Py_ssize_t i, count = __Pyx_PyList_GET_SIZE(cyfunctions);
|
|
1572
|
+
#if !CYTHON_ASSUME_SAFE_SIZE
|
|
1573
|
+
if (unlikely(count < 0)) return -1;
|
|
1574
|
+
#endif
|
|
1575
|
+
|
|
1576
|
+
for (i = 0; i < count; i++) {
|
|
1577
|
+
PyObject *m =
|
|
1578
|
+
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && !CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
|
|
1579
|
+
PyList_GET_ITEM(cyfunctions, i);
|
|
1580
|
+
#else
|
|
1581
|
+
__Pyx_PySequence_ITEM(cyfunctions, i);
|
|
1582
|
+
if (unlikely(!m))
|
|
1583
|
+
return -1;
|
|
1584
|
+
#endif
|
|
1585
|
+
__Pyx_CyFunction_SetClassObj(m, classobj);
|
|
1586
|
+
#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && !CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)
|
|
1587
|
+
Py_DECREF(m);
|
|
1588
|
+
#endif
|
|
1589
|
+
}
|
|
1590
|
+
return 0;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
//////////////////// FusedFunctionPerModule.module_state_decls ////////////////////
|
|
1594
|
+
|
|
1595
|
+
PyTypeObject *__pyx_FusedFunctionType;
|
|
1596
|
+
|
|
1597
|
+
//////////////////// FusedFunctionPerModule.module_state_traverse ///////////////////
|
|
1598
|
+
|
|
1599
|
+
Py_VISIT(traverse_module_state->__pyx_FusedFunctionType);
|
|
1600
|
+
|
|
1601
|
+
//////////////////// FusedFunctionPerModule.module_state_clear ///////////////////
|
|
1602
|
+
|
|
1603
|
+
Py_CLEAR(clear_module_state->__pyx_FusedFunctionType);
|
|
1604
|
+
|
|
1605
|
+
//////////////////// FusedFunctionPerModule.init //////////////////
|
|
1606
|
+
//@substitute: naming
|
|
1607
|
+
//@init_block: init_after_shared_utility
|
|
1608
|
+
|
|
1609
|
+
if (likely(__pyx_FusedFunction_init($module_cname) == 0)); else
|
|
1610
|
+
|
|
1611
|
+
//////////////////// FusedFunctionPerModule.proto ////////////////
|
|
1612
|
+
//@requires: CythonFunctionPerModule
|
|
1613
|
+
|
|
1614
|
+
#if CYTHON_OPAQUE_SHARED_TYPES
|
|
1615
|
+
#define __Pyx_as_FusedFunctionObject(o) ((__pyx_FusedFunctionObject *)PyObject_GetTypeData((o), CGLOBAL(__pyx_FusedFunctionType)))
|
|
1616
|
+
#else
|
|
1617
|
+
#define __Pyx_as_FusedFunctionObject(o) ((__pyx_FusedFunctionObject*)o)
|
|
1618
|
+
#endif
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
typedef struct {
|
|
1622
|
+
#if !(CYTHON_COMPILING_IN_LIMITED_API && CYTHON_OPAQUE_OBJECTS)
|
|
1623
|
+
__pyx_CyFunctionObject func;
|
|
1624
|
+
#endif
|
|
1625
|
+
PyObject *__signatures__;
|
|
1626
|
+
PyObject *self;
|
|
1627
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1628
|
+
PyMethodDef *ml;
|
|
1629
|
+
#endif
|
|
1630
|
+
} __pyx_FusedFunctionObject;
|
|
1631
|
+
|
|
1632
|
+
// Definition depends on whether we're using shared utility code or not
|
|
1633
|
+
static int __pyx_FusedFunction_init(PyObject *module);
|
|
1634
|
+
|
|
1635
|
+
#define __Pyx_FusedFunction_USED
|
|
1636
|
+
|
|
1637
|
+
//////////////////// FusedFunctionFromSharedModule /////////////////////
|
|
1638
|
+
//@requires: FusedFunctionPerModule
|
|
1639
|
+
//@requires: CythonFunctionFromSharedModule
|
|
1640
|
+
//@requires: CommonStructures.c::VerifyCachedType
|
|
1641
|
+
//@requires: FusedFunction
|
|
1642
|
+
//@substitute: naming
|
|
1643
|
+
|
|
1644
|
+
// Cutdown version that's only used when importing from shared utility code
|
|
1645
|
+
static int __pyx_FusedFunction_init(PyObject *module) {
|
|
1646
|
+
$modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
|
|
1647
|
+
|
|
1648
|
+
PyTypeObject *tp = __Pyx_Get_FusedFunction_Type();
|
|
1649
|
+
if (!tp) return -1;
|
|
1650
|
+
|
|
1651
|
+
if (__Pyx_VerifyCachedType((PyObject*)tp,
|
|
1652
|
+
__PYX_TYPE_MODULE_PREFIX "fused_cython_function",
|
|
1653
|
+
__PYX_SHARED_SIZEOF(__pyx_FusedFunctionObject)) != 0) {
|
|
1654
|
+
Py_DECREF((PyObject*)tp);
|
|
1655
|
+
return -1;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
mstate->__pyx_FusedFunctionType = tp;
|
|
1659
|
+
return 0;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
//////////////////// FusedFunction.export ////////////////////
|
|
1663
|
+
|
|
1664
|
+
static PyObject *__pyx_FusedFunction_New(PyMethodDef *ml, int flags,
|
|
1665
|
+
PyObject *qualname, PyObject *closure,
|
|
1666
|
+
PyObject *module, PyObject *globals,
|
|
1667
|
+
PyObject *code);
|
|
1668
|
+
|
|
1669
|
+
static PyTypeObject *__Pyx_Get_FusedFunction_Type(void);
|
|
1670
|
+
|
|
1671
|
+
//////////////////// FusedFunction ////////////////////
|
|
1672
|
+
//@requires: CythonFunctionShared
|
|
1673
|
+
//@requires: FusedFunctionPerModule
|
|
1674
|
+
//@substitute: naming
|
|
1675
|
+
|
|
1676
|
+
static PyObject *
|
|
1677
|
+
__pyx_FusedFunction_New(PyMethodDef *ml, int flags,
|
|
1678
|
+
PyObject *qualname, PyObject *closure,
|
|
1679
|
+
PyObject *module, PyObject *globals,
|
|
1680
|
+
PyObject *code)
|
|
1681
|
+
{
|
|
1682
|
+
PyObject *op = __Pyx_CyFunction_Init(
|
|
1683
|
+
PyObject_GC_New(PyObject, CGLOBAL(__pyx_FusedFunctionType)),
|
|
1684
|
+
ml, flags, qualname, closure, module, globals, code
|
|
1685
|
+
);
|
|
1686
|
+
if (likely(op)) {
|
|
1687
|
+
__pyx_FusedFunctionObject *fusedfunc = __Pyx_as_FusedFunctionObject(op);
|
|
1688
|
+
fusedfunc->__signatures__ = NULL;
|
|
1689
|
+
fusedfunc->self = NULL;
|
|
1690
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1691
|
+
fusedfunc->ml = ml;
|
|
1692
|
+
#endif
|
|
1693
|
+
PyObject_GC_Track(op);
|
|
1694
|
+
}
|
|
1695
|
+
return op;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
static void
|
|
1699
|
+
__pyx_FusedFunction_dealloc(PyObject *self)
|
|
1700
|
+
{
|
|
1701
|
+
__pyx_FusedFunctionObject *fused = __Pyx_as_FusedFunctionObject(self);
|
|
1702
|
+
PyObject_GC_UnTrack(self);
|
|
1703
|
+
Py_CLEAR(fused->self);
|
|
1704
|
+
Py_CLEAR(fused->__signatures__);
|
|
1705
|
+
__Pyx__CyFunction_dealloc(self);
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
static int
|
|
1709
|
+
__pyx_FusedFunction_traverse(PyObject *self,
|
|
1710
|
+
visitproc visit,
|
|
1711
|
+
void *arg)
|
|
1712
|
+
{
|
|
1713
|
+
__pyx_FusedFunctionObject *fused = __Pyx_as_FusedFunctionObject(self);
|
|
1714
|
+
// Visiting the type is handled in the CyFunction traverse if needed
|
|
1715
|
+
Py_VISIT(fused->self);
|
|
1716
|
+
Py_VISIT(fused->__signatures__);
|
|
1717
|
+
return __Pyx_CyFunction_traverse(self, visit, arg);
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
static int
|
|
1721
|
+
__pyx_FusedFunction_clear(PyObject *self)
|
|
1722
|
+
{
|
|
1723
|
+
__pyx_FusedFunctionObject *fused = __Pyx_as_FusedFunctionObject(self);
|
|
1724
|
+
Py_CLEAR(fused->self);
|
|
1725
|
+
Py_CLEAR(fused->__signatures__);
|
|
1726
|
+
return __Pyx_CyFunction_clear(self);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
|
|
1730
|
+
static PyObject *__Pyx_FusedFunction_get_signatures(PyObject *self, void *closure)
|
|
1731
|
+
{
|
|
1732
|
+
CYTHON_UNUSED_VAR(closure);
|
|
1733
|
+
// No critical section - signatures should not be reassigned
|
|
1734
|
+
__pyx_FusedFunctionObject *func = __Pyx_as_FusedFunctionObject(self);
|
|
1735
|
+
if (func->__signatures__) {
|
|
1736
|
+
// A dictproxy ensures that users can't (easily) mess with the internal data used in fused dispatch.
|
|
1737
|
+
// For this rarely-used introspection function, it is unlikely to be worth the memory to cache the proxy.
|
|
1738
|
+
return PyDictProxy_New(func->__signatures__);
|
|
1739
|
+
} else {
|
|
1740
|
+
Py_RETURN_NONE;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
static PyObject *
|
|
1745
|
+
__pyx_FusedFunction_descr_get_locked(PyObject *self, PyObject *obj)
|
|
1746
|
+
{
|
|
1747
|
+
__pyx_FusedFunctionObject *func = __Pyx_as_FusedFunctionObject(self);
|
|
1748
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(self);
|
|
1749
|
+
PyObject *module;
|
|
1750
|
+
PyObject *meth;
|
|
1751
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1752
|
+
module = __Pyx_CyFunction_get_module(self, NULL);
|
|
1753
|
+
if ((unlikely(!module))) return NULL;
|
|
1754
|
+
#else
|
|
1755
|
+
module = ((PyCFunctionObject *) func)->m_module;
|
|
1756
|
+
#endif
|
|
1757
|
+
|
|
1758
|
+
meth = __pyx_FusedFunction_New(
|
|
1759
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1760
|
+
func->ml,
|
|
1761
|
+
#else
|
|
1762
|
+
((PyCFunctionObject *) func)->m_ml,
|
|
1763
|
+
#endif
|
|
1764
|
+
cyfunc->flags,
|
|
1765
|
+
cyfunc->func_qualname,
|
|
1766
|
+
cyfunc->func_closure,
|
|
1767
|
+
module,
|
|
1768
|
+
cyfunc->func_globals,
|
|
1769
|
+
cyfunc->func_code);
|
|
1770
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
1771
|
+
Py_DECREF(module);
|
|
1772
|
+
#endif
|
|
1773
|
+
if (unlikely(!meth))
|
|
1774
|
+
return NULL;
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
__pyx_CyFunctionObject *meth_as_cyfunc = __Pyx_as_CyFunctionObject(meth);
|
|
1778
|
+
__pyx_FusedFunctionObject *meth_as_fused = __Pyx_as_FusedFunctionObject(meth);
|
|
1779
|
+
Py_XINCREF(cyfunc->defaults);
|
|
1780
|
+
meth_as_cyfunc->defaults = cyfunc->defaults;
|
|
1781
|
+
|
|
1782
|
+
__Pyx_CyFunction_SetClassObj(meth, __Pyx__CyFunction_GetClassObj(cyfunc));
|
|
1783
|
+
|
|
1784
|
+
Py_XINCREF(func->__signatures__);
|
|
1785
|
+
meth_as_fused->__signatures__ = func->__signatures__;
|
|
1786
|
+
|
|
1787
|
+
Py_XINCREF(cyfunc->defaults_tuple);
|
|
1788
|
+
meth_as_cyfunc->defaults_tuple = cyfunc->defaults_tuple;
|
|
1789
|
+
|
|
1790
|
+
Py_XINCREF(obj);
|
|
1791
|
+
meth_as_fused->self = obj;
|
|
1792
|
+
return meth;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
static PyObject *
|
|
1796
|
+
__pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
|
1797
|
+
{
|
|
1798
|
+
__pyx_FusedFunctionObject *func = __Pyx_as_FusedFunctionObject(self);
|
|
1799
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(self);
|
|
1800
|
+
PyObject *meth;
|
|
1801
|
+
|
|
1802
|
+
if (func->self || cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
|
|
1803
|
+
// Do not allow rebinding and don't do anything for static methods
|
|
1804
|
+
Py_INCREF(self);
|
|
1805
|
+
return self;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
if (obj == Py_None)
|
|
1809
|
+
obj = NULL;
|
|
1810
|
+
|
|
1811
|
+
if (cyfunc->flags & __Pyx_CYFUNCTION_CLASSMETHOD)
|
|
1812
|
+
obj = type;
|
|
1813
|
+
|
|
1814
|
+
if (obj == NULL) {
|
|
1815
|
+
// We aren't actually binding to anything, save the effort of rebinding
|
|
1816
|
+
Py_INCREF(self);
|
|
1817
|
+
return self;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
__Pyx_BEGIN_CRITICAL_SECTION(self);
|
|
1821
|
+
meth = __pyx_FusedFunction_descr_get_locked(self, obj);
|
|
1822
|
+
__Pyx_END_CRITICAL_SECTION()
|
|
1823
|
+
|
|
1824
|
+
return meth;
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
static PyObject *
|
|
1828
|
+
__pyx_FusedFunction_obj_to_string(PyObject *obj)
|
|
1829
|
+
{
|
|
1830
|
+
if (PyUnicode_CheckExact(obj))
|
|
1831
|
+
return __Pyx_NewRef(obj);
|
|
1832
|
+
else if (PyType_Check(obj))
|
|
1833
|
+
return PyObject_GetAttr(obj, PYIDENT("__name__"));
|
|
1834
|
+
else
|
|
1835
|
+
return PyObject_Str(obj);
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
static PyObject *
|
|
1839
|
+
__pyx_FusedFunction_getitem(PyObject *self, PyObject *idx)
|
|
1840
|
+
{
|
|
1841
|
+
PyObject *signature = NULL;
|
|
1842
|
+
PyObject *unbound_result_func;
|
|
1843
|
+
PyObject *result_func = NULL;
|
|
1844
|
+
__pyx_FusedFunctionObject *fusedfunc = __Pyx_as_FusedFunctionObject(self);
|
|
1845
|
+
|
|
1846
|
+
if (unlikely(fusedfunc->__signatures__ == NULL)) {
|
|
1847
|
+
PyErr_SetString(PyExc_TypeError, "Function is not fused");
|
|
1848
|
+
return NULL;
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
if (PyTuple_Check(idx)) {
|
|
1852
|
+
Py_ssize_t n = __Pyx_PyTuple_GET_SIZE(idx);
|
|
1853
|
+
PyObject *list;
|
|
1854
|
+
int i;
|
|
1855
|
+
#if !CYTHON_ASSUME_SAFE_SIZE
|
|
1856
|
+
if (unlikely(n < 0)) return NULL;
|
|
1857
|
+
#endif
|
|
1858
|
+
|
|
1859
|
+
list = PyList_New(n);
|
|
1860
|
+
if (unlikely(!list))
|
|
1861
|
+
return NULL;
|
|
1862
|
+
|
|
1863
|
+
for (i = 0; i < n; i++) {
|
|
1864
|
+
PyObject *string;
|
|
1865
|
+
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
|
|
1866
|
+
PyObject *item = PyTuple_GET_ITEM(idx, i);
|
|
1867
|
+
#else
|
|
1868
|
+
PyObject *item = __Pyx_PySequence_ITEM(idx, i); if (unlikely(!item)) goto __pyx_err;
|
|
1869
|
+
#endif
|
|
1870
|
+
string = __pyx_FusedFunction_obj_to_string(item);
|
|
1871
|
+
#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
|
|
1872
|
+
Py_DECREF(item);
|
|
1873
|
+
#endif
|
|
1874
|
+
if (unlikely(!string)) goto __pyx_err;
|
|
1875
|
+
if (__Pyx_PyList_SET_ITEM(list, i, string) < (0)) goto __pyx_err;
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
signature = PyUnicode_Join(PYUNICODE("|"), list);
|
|
1879
|
+
__pyx_err:;
|
|
1880
|
+
Py_DECREF(list);
|
|
1881
|
+
} else {
|
|
1882
|
+
signature = __pyx_FusedFunction_obj_to_string(idx);
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
if (unlikely(!signature))
|
|
1886
|
+
return NULL;
|
|
1887
|
+
|
|
1888
|
+
unbound_result_func = PyObject_GetItem(fusedfunc->__signatures__, signature);
|
|
1889
|
+
|
|
1890
|
+
if (likely(unbound_result_func)) {
|
|
1891
|
+
if (fusedfunc->self) {
|
|
1892
|
+
assert(__Pyx_CyFunction_GetClassObj(unbound_result_func) == __Pyx_CyFunction_GetClassObj(self));
|
|
1893
|
+
|
|
1894
|
+
result_func = __pyx_FusedFunction_descr_get(unbound_result_func,
|
|
1895
|
+
fusedfunc->self, fusedfunc->self);
|
|
1896
|
+
} else {
|
|
1897
|
+
result_func = unbound_result_func;
|
|
1898
|
+
Py_INCREF(result_func);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
Py_DECREF(signature);
|
|
1903
|
+
Py_XDECREF(unbound_result_func);
|
|
1904
|
+
|
|
1905
|
+
return result_func;
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
static PyObject *
|
|
1909
|
+
__pyx_FusedFunction_callfunction(PyObject *func, PyObject *args, PyObject *kw)
|
|
1910
|
+
{
|
|
1911
|
+
__pyx_FusedFunctionObject *fusedfunc = __Pyx_as_FusedFunctionObject(func);
|
|
1912
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
|
|
1913
|
+
|
|
1914
|
+
int static_specialized = (cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD &&
|
|
1915
|
+
!fusedfunc->__signatures__);
|
|
1916
|
+
|
|
1917
|
+
if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !static_specialized) {
|
|
1918
|
+
return __Pyx_CyFunction_CallAsMethod(func, args, kw);
|
|
1919
|
+
} else {
|
|
1920
|
+
return __Pyx_CyFunction_Call(func, args, kw);
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
// Note: the 'self' from method binding is passed in in the args tuple,
|
|
1925
|
+
// whereas the FusedFunction object is passed in as the first
|
|
1926
|
+
// argument to the C function. For extension methods we
|
|
1927
|
+
// don't want to pass 'self' as the first element of the
|
|
1928
|
+
// args tuple.
|
|
1929
|
+
|
|
1930
|
+
static PyObject *
|
|
1931
|
+
__pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
|
|
1932
|
+
{
|
|
1933
|
+
__pyx_FusedFunctionObject *binding_func = __Pyx_as_FusedFunctionObject(func);
|
|
1934
|
+
__pyx_CyFunctionObject *cyfunc = __Pyx_as_CyFunctionObject(func);
|
|
1935
|
+
|
|
1936
|
+
Py_ssize_t argc = __Pyx_PyTuple_GET_SIZE(args);
|
|
1937
|
+
PyObject *new_args = NULL;
|
|
1938
|
+
PyObject *new_func = NULL;
|
|
1939
|
+
PyObject *result = NULL;
|
|
1940
|
+
int is_staticmethod = cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD;
|
|
1941
|
+
#if !CYTHON_ASSUME_SAFE_SIZE
|
|
1942
|
+
if (unlikely(argc < 0)) return NULL;
|
|
1943
|
+
#endif
|
|
1944
|
+
|
|
1945
|
+
if (binding_func->self) {
|
|
1946
|
+
// Bound method call, put 'self' in the args tuple
|
|
1947
|
+
PyObject *self;
|
|
1948
|
+
Py_ssize_t i;
|
|
1949
|
+
new_args = PyTuple_New(argc + 1);
|
|
1950
|
+
if (unlikely(!new_args))
|
|
1951
|
+
return NULL;
|
|
1952
|
+
|
|
1953
|
+
self = binding_func->self;
|
|
1954
|
+
|
|
1955
|
+
Py_INCREF(self);
|
|
1956
|
+
if (__Pyx_PyTuple_SET_ITEM(new_args, 0, self) < (0)) goto bad;
|
|
1957
|
+
self = NULL;
|
|
1958
|
+
|
|
1959
|
+
for (i = 0; i < argc; i++) {
|
|
1960
|
+
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
|
|
1961
|
+
PyObject *item = PyTuple_GET_ITEM(args, i);
|
|
1962
|
+
Py_INCREF(item);
|
|
1963
|
+
#else
|
|
1964
|
+
PyObject *item = __Pyx_PySequence_ITEM(args, i); if (unlikely(!item)) goto bad;
|
|
1965
|
+
#endif
|
|
1966
|
+
if (__Pyx_PyTuple_SET_ITEM(new_args, i + 1, item) < (0)) goto bad;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
args = new_args;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
if (binding_func->__signatures__) {
|
|
1973
|
+
PyObject *tup;
|
|
1974
|
+
if (is_staticmethod && cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) {
|
|
1975
|
+
// FIXME: this seems wrong, but we must currently pass the signatures dict as 'self' argument
|
|
1976
|
+
tup = PyTuple_Pack(3, args,
|
|
1977
|
+
kw == NULL ? Py_None : kw,
|
|
1978
|
+
cyfunc->defaults_tuple);
|
|
1979
|
+
if (unlikely(!tup)) goto bad;
|
|
1980
|
+
new_func = __Pyx_CyFunction_CallMethod(
|
|
1981
|
+
func, binding_func->__signatures__, tup, NULL);
|
|
1982
|
+
} else {
|
|
1983
|
+
tup = PyTuple_Pack(4, binding_func->__signatures__, args,
|
|
1984
|
+
kw == NULL ? Py_None : kw,
|
|
1985
|
+
cyfunc->defaults_tuple);
|
|
1986
|
+
if (unlikely(!tup)) goto bad;
|
|
1987
|
+
new_func = __pyx_FusedFunction_callfunction(func, tup, NULL);
|
|
1988
|
+
}
|
|
1989
|
+
Py_DECREF(tup);
|
|
1990
|
+
|
|
1991
|
+
if (unlikely(!new_func))
|
|
1992
|
+
goto bad;
|
|
1993
|
+
|
|
1994
|
+
assert(__Pyx_CyFunction_GetClassObj(new_func) == __Pyx_CyFunction_GetClassObj(func));
|
|
1995
|
+
|
|
1996
|
+
func = new_func;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
result = __pyx_FusedFunction_callfunction(func, args, kw);
|
|
2000
|
+
bad:
|
|
2001
|
+
Py_XDECREF(new_args);
|
|
2002
|
+
Py_XDECREF(new_func);
|
|
2003
|
+
return result;
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
static PyMemberDef __pyx_FusedFunction_members[] = {
|
|
2007
|
+
{"__self__", T_OBJECT_EX, offsetof(__pyx_FusedFunctionObject, self), __PYX_SHARED_RELATIVE_OFFSET | READONLY, 0},
|
|
2008
|
+
// For heap-types __module__ appears not to be inherited (so redeclare)
|
|
2009
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
2010
|
+
{"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
|
|
2011
|
+
#endif
|
|
2012
|
+
{0, 0, 0, 0, 0},
|
|
2013
|
+
};
|
|
2014
|
+
|
|
2015
|
+
static PyGetSetDef __pyx_FusedFunction_getsets[] = {
|
|
2016
|
+
// __doc__ is None for the fused function type, but we need it to be
|
|
2017
|
+
// a descriptor for the instance's __doc__, so rebuild the descriptor in our subclass
|
|
2018
|
+
// (all other descriptors are inherited)
|
|
2019
|
+
{"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
|
|
2020
|
+
// For heap-types __module__ appears not to be inherited (so redeclare)
|
|
2021
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
2022
|
+
{"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
|
|
2023
|
+
#endif
|
|
2024
|
+
{"__signatures__", (getter)__Pyx_FusedFunction_get_signatures, NULL, 0, 0},
|
|
2025
|
+
{0, 0, 0, 0, 0}
|
|
2026
|
+
};
|
|
2027
|
+
|
|
2028
|
+
static PyType_Slot __pyx_FusedFunctionType_slots[] = {
|
|
2029
|
+
{Py_tp_dealloc, (void *)__pyx_FusedFunction_dealloc},
|
|
2030
|
+
{Py_tp_call, (void *)__pyx_FusedFunction_call},
|
|
2031
|
+
{Py_tp_traverse, (void *)__pyx_FusedFunction_traverse},
|
|
2032
|
+
{Py_tp_clear, (void *)__pyx_FusedFunction_clear},
|
|
2033
|
+
{Py_tp_members, (void *)__pyx_FusedFunction_members},
|
|
2034
|
+
{Py_tp_getset, (void *)__pyx_FusedFunction_getsets},
|
|
2035
|
+
{Py_tp_descr_get, (void *)__pyx_FusedFunction_descr_get},
|
|
2036
|
+
{Py_mp_subscript, (void *)__pyx_FusedFunction_getitem},
|
|
2037
|
+
{0, 0},
|
|
2038
|
+
};
|
|
2039
|
+
|
|
2040
|
+
static PyType_Spec __pyx_FusedFunctionType_spec = {
|
|
2041
|
+
__PYX_TYPE_MODULE_PREFIX "fused_cython_function",
|
|
2042
|
+
__PYX_SHARED_SIZEOF(__pyx_FusedFunctionObject),
|
|
2043
|
+
0,
|
|
2044
|
+
Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
|
|
2045
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC , /*tp_flags*/
|
|
2046
|
+
__pyx_FusedFunctionType_slots
|
|
2047
|
+
};
|
|
2048
|
+
|
|
2049
|
+
static int __pyx_FusedFunction_init(PyObject *module) {
|
|
2050
|
+
// Silence unused warning when not in shared module.
|
|
2051
|
+
(void)__Pyx_Get_FusedFunction_Type;
|
|
2052
|
+
|
|
2053
|
+
$modulestatetype_cname *mstate = __Pyx_PyModule_GetState(module);
|
|
2054
|
+
PyObject *bases = PyTuple_Pack(1, mstate->__pyx_CyFunctionType);
|
|
2055
|
+
if (unlikely(!bases)) {
|
|
2056
|
+
return -1;
|
|
2057
|
+
}
|
|
2058
|
+
mstate->__pyx_FusedFunctionType = __Pyx_FetchCommonTypeFromSpec(
|
|
2059
|
+
mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_FusedFunctionType_spec, bases);
|
|
2060
|
+
Py_DECREF(bases);
|
|
2061
|
+
if (unlikely(mstate->__pyx_FusedFunctionType == NULL)) {
|
|
2062
|
+
return -1;
|
|
2063
|
+
}
|
|
2064
|
+
return 0;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
static PyTypeObject *__Pyx_Get_FusedFunction_Type(void) {
|
|
2068
|
+
PyTypeObject *tp = CGLOBAL(__pyx_FusedFunctionType);
|
|
2069
|
+
Py_INCREF((PyObject*)tp);
|
|
2070
|
+
return tp;
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
|
|
2074
|
+
//////////////////// FusedFunctionArgTypeError.proto ////////////////////
|
|
2075
|
+
|
|
2076
|
+
#define __Pyx_RaiseFusedFunctionArgTypeError(arg_name, arg_tuple_idx, min_positional_args, arg_count) \
|
|
2077
|
+
(__Pyx__RaiseFusedFunctionArgTypeError(arg_name, arg_tuple_idx, min_positional_args, arg_count), -1)
|
|
2078
|
+
|
|
2079
|
+
static void __Pyx__RaiseFusedFunctionArgTypeError(PyObject *arg_name, Py_ssize_t arg_tuple_idx, Py_ssize_t min_positional_args, Py_ssize_t arg_count); /*proto*/
|
|
2080
|
+
|
|
2081
|
+
//////////////////// FusedFunctionArgTypeError ////////////////////
|
|
2082
|
+
|
|
2083
|
+
static void __Pyx__RaiseFusedFunctionArgTypeError(PyObject *arg_name, Py_ssize_t arg_tuple_idx, Py_ssize_t min_positional_args, Py_ssize_t arg_count) {
|
|
2084
|
+
if (arg_tuple_idx < min_positional_args) {
|
|
2085
|
+
PyErr_Format(
|
|
2086
|
+
PyExc_TypeError,
|
|
2087
|
+
"Expected at least %zd argument%.1s, got %zd",
|
|
2088
|
+
min_positional_args,
|
|
2089
|
+
(min_positional_args != 1) ? "s" : "",
|
|
2090
|
+
arg_count
|
|
2091
|
+
);
|
|
2092
|
+
} else {
|
|
2093
|
+
PyErr_Format(
|
|
2094
|
+
PyExc_TypeError,
|
|
2095
|
+
"Missing keyword-only argument: '%U'",
|
|
2096
|
+
arg_name
|
|
2097
|
+
);
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
|
|
2102
|
+
//////////////////// ClassMethod.proto ////////////////////
|
|
2103
|
+
|
|
2104
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
2105
|
+
#include "descrobject.h"
|
|
2106
|
+
#endif
|
|
2107
|
+
CYTHON_UNUSED static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/
|
|
2108
|
+
|
|
2109
|
+
//////////////////// ClassMethod ////////////////////
|
|
2110
|
+
//@requires: ObjectHandling.c::CachedMethodType
|
|
2111
|
+
//@requires: ModuleSetupCode.c::FastTypeChecks
|
|
2112
|
+
|
|
2113
|
+
static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
|
|
2114
|
+
#if CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM <= 0x05080000
|
|
2115
|
+
if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) {
|
|
2116
|
+
// cdef classes
|
|
2117
|
+
return PyClassMethod_New(method);
|
|
2118
|
+
}
|
|
2119
|
+
#else
|
|
2120
|
+
#if CYTHON_COMPILING_IN_PYPY
|
|
2121
|
+
// special C-API function only in PyPy >= 5.9
|
|
2122
|
+
if (PyMethodDescr_Check(method))
|
|
2123
|
+
#else
|
|
2124
|
+
if (__Pyx_TypeCheck(method, &PyMethodDescr_Type))
|
|
2125
|
+
#endif
|
|
2126
|
+
{
|
|
2127
|
+
#if CYTHON_COMPILING_IN_LIMITED_API
|
|
2128
|
+
return PyErr_Format(
|
|
2129
|
+
PyExc_SystemError,
|
|
2130
|
+
"Cython cannot yet handle classmethod on a MethodDescriptorType (%S) in limited API mode. "
|
|
2131
|
+
"This is most likely a classmethod in a cdef class method with binding=False. "
|
|
2132
|
+
"Try setting 'binding' to True.",
|
|
2133
|
+
method);
|
|
2134
|
+
#elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
|
|
2135
|
+
// cdef classes
|
|
2136
|
+
PyTypeObject *d_type = GraalPyDescrObject_GetType(method);
|
|
2137
|
+
return PyDescr_NewClassMethod(d_type, GraalPyMethodDescrObject_GetMethod(method));
|
|
2138
|
+
#elif CYTHON_COMPILING_IN_GRAAL
|
|
2139
|
+
// Remove when GraalPy 24 goes EOL
|
|
2140
|
+
PyTypeObject *d_type = PyDescrObject_GetType(method);
|
|
2141
|
+
return PyDescr_NewClassMethod(d_type, PyMethodDescrObject_GetMethod(method));
|
|
2142
|
+
#else
|
|
2143
|
+
// cdef classes
|
|
2144
|
+
PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
|
|
2145
|
+
PyTypeObject *d_type = descr->d_common.d_type;
|
|
2146
|
+
return PyDescr_NewClassMethod(d_type, descr->d_method);
|
|
2147
|
+
#endif
|
|
2148
|
+
}
|
|
2149
|
+
#endif
|
|
2150
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API
|
|
2151
|
+
else if (PyMethod_Check(method)) {
|
|
2152
|
+
// python classes
|
|
2153
|
+
return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
|
|
2154
|
+
}
|
|
2155
|
+
else {
|
|
2156
|
+
return PyClassMethod_New(method);
|
|
2157
|
+
}
|
|
2158
|
+
#else
|
|
2159
|
+
{
|
|
2160
|
+
PyObject *func=NULL;
|
|
2161
|
+
PyObject *builtins, *classmethod, *classmethod_str, *result=NULL;
|
|
2162
|
+
if (__Pyx_TypeCheck(method, CGLOBAL(__Pyx_CachedMethodType))) {
|
|
2163
|
+
func = PyObject_GetAttrString(method, "__func__");
|
|
2164
|
+
if (!func) goto bad;
|
|
2165
|
+
} else {
|
|
2166
|
+
func = method;
|
|
2167
|
+
Py_INCREF(func);
|
|
2168
|
+
}
|
|
2169
|
+
builtins = PyEval_GetBuiltins(); // borrowed
|
|
2170
|
+
if (unlikely(!builtins)) goto bad;
|
|
2171
|
+
classmethod_str = PyUnicode_FromString("classmethod");
|
|
2172
|
+
if (unlikely(!classmethod_str)) goto bad;
|
|
2173
|
+
classmethod = PyObject_GetItem(builtins, classmethod_str);
|
|
2174
|
+
Py_DECREF(classmethod_str);
|
|
2175
|
+
if (unlikely(!classmethod)) goto bad;
|
|
2176
|
+
result = PyObject_CallFunctionObjArgs(classmethod, func, NULL);
|
|
2177
|
+
Py_DECREF(classmethod);
|
|
2178
|
+
|
|
2179
|
+
bad:
|
|
2180
|
+
Py_XDECREF(func);
|
|
2181
|
+
return result;
|
|
2182
|
+
}
|
|
2183
|
+
#endif
|
|
2184
|
+
|
|
2185
|
+
}
|