]>
Commit | Line | Data |
---|---|---|
c8042e10 DM |
1 | #ifndef Py_CEVAL_H\r |
2 | #define Py_CEVAL_H\r | |
3 | #ifdef __cplusplus\r | |
4 | extern "C" {\r | |
5 | #endif\r | |
6 | \r | |
7 | \r | |
8 | /* Interface to random parts in ceval.c */\r | |
9 | \r | |
10 | PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(\r | |
11 | PyObject *, PyObject *, PyObject *);\r | |
12 | \r | |
13 | /* Inline this */\r | |
14 | #define PyEval_CallObject(func,arg) \\r | |
15 | PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)\r | |
16 | \r | |
17 | PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj,\r | |
18 | const char *format, ...);\r | |
19 | PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,\r | |
20 | const char *methodname,\r | |
21 | const char *format, ...);\r | |
22 | \r | |
23 | PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);\r | |
24 | PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);\r | |
25 | \r | |
26 | struct _frame; /* Avoid including frameobject.h */\r | |
27 | \r | |
28 | PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);\r | |
29 | PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);\r | |
30 | PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);\r | |
31 | PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);\r | |
32 | PyAPI_FUNC(int) PyEval_GetRestricted(void);\r | |
33 | \r | |
34 | /* Look at the current frame's (if any) code's co_flags, and turn on\r | |
35 | the corresponding compiler flags in cf->cf_flags. Return 1 if any\r | |
36 | flag was set, else return 0. */\r | |
37 | PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);\r | |
38 | \r | |
39 | PyAPI_FUNC(int) Py_FlushLine(void);\r | |
40 | \r | |
41 | PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);\r | |
42 | PyAPI_FUNC(int) Py_MakePendingCalls(void);\r | |
43 | \r | |
44 | /* Protection against deeply nested recursive calls */\r | |
45 | PyAPI_FUNC(void) Py_SetRecursionLimit(int);\r | |
46 | PyAPI_FUNC(int) Py_GetRecursionLimit(void);\r | |
47 | \r | |
48 | #define Py_EnterRecursiveCall(where) \\r | |
49 | (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \\r | |
50 | _Py_CheckRecursiveCall(where))\r | |
51 | #define Py_LeaveRecursiveCall() \\r | |
52 | (--PyThreadState_GET()->recursion_depth)\r | |
53 | PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where);\r | |
54 | PyAPI_DATA(int) _Py_CheckRecursionLimit;\r | |
55 | #ifdef USE_STACKCHECK\r | |
56 | # define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit)\r | |
57 | #else\r | |
58 | # define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)\r | |
59 | #endif\r | |
60 | \r | |
61 | PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);\r | |
62 | PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);\r | |
63 | \r | |
64 | PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);\r | |
65 | PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);\r | |
66 | PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc);\r | |
67 | \r | |
68 | /* this used to be handled on a per-thread basis - now just two globals */\r | |
69 | PyAPI_DATA(volatile int) _Py_Ticker;\r | |
70 | PyAPI_DATA(int) _Py_CheckInterval;\r | |
71 | \r | |
72 | /* Interface for threads.\r | |
73 | \r | |
74 | A module that plans to do a blocking system call (or something else\r | |
75 | that lasts a long time and doesn't touch Python data) can allow other\r | |
76 | threads to run as follows:\r | |
77 | \r | |
78 | ...preparations here...\r | |
79 | Py_BEGIN_ALLOW_THREADS\r | |
80 | ...blocking system call here...\r | |
81 | Py_END_ALLOW_THREADS\r | |
82 | ...interpret result here...\r | |
83 | \r | |
84 | The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a\r | |
85 | {}-surrounded block.\r | |
86 | To leave the block in the middle (e.g., with return), you must insert\r | |
87 | a line containing Py_BLOCK_THREADS before the return, e.g.\r | |
88 | \r | |
89 | if (...premature_exit...) {\r | |
90 | Py_BLOCK_THREADS\r | |
91 | PyErr_SetFromErrno(PyExc_IOError);\r | |
92 | return NULL;\r | |
93 | }\r | |
94 | \r | |
95 | An alternative is:\r | |
96 | \r | |
97 | Py_BLOCK_THREADS\r | |
98 | if (...premature_exit...) {\r | |
99 | PyErr_SetFromErrno(PyExc_IOError);\r | |
100 | return NULL;\r | |
101 | }\r | |
102 | Py_UNBLOCK_THREADS\r | |
103 | \r | |
104 | For convenience, that the value of 'errno' is restored across\r | |
105 | Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.\r | |
106 | \r | |
107 | WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND\r | |
108 | Py_END_ALLOW_THREADS!!!\r | |
109 | \r | |
110 | The function PyEval_InitThreads() should be called only from\r | |
111 | initthread() in "threadmodule.c".\r | |
112 | \r | |
113 | Note that not yet all candidates have been converted to use this\r | |
114 | mechanism!\r | |
115 | */\r | |
116 | \r | |
117 | PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);\r | |
118 | PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);\r | |
119 | \r | |
120 | #ifdef WITH_THREAD\r | |
121 | \r | |
122 | PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);\r | |
123 | PyAPI_FUNC(void) PyEval_InitThreads(void);\r | |
124 | PyAPI_FUNC(void) PyEval_AcquireLock(void);\r | |
125 | PyAPI_FUNC(void) PyEval_ReleaseLock(void);\r | |
126 | PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);\r | |
127 | PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);\r | |
128 | PyAPI_FUNC(void) PyEval_ReInitThreads(void);\r | |
129 | \r | |
130 | #define Py_BEGIN_ALLOW_THREADS { \\r | |
131 | PyThreadState *_save; \\r | |
132 | _save = PyEval_SaveThread();\r | |
133 | #define Py_BLOCK_THREADS PyEval_RestoreThread(_save);\r | |
134 | #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();\r | |
135 | #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \\r | |
136 | }\r | |
137 | \r | |
138 | #else /* !WITH_THREAD */\r | |
139 | \r | |
140 | #define Py_BEGIN_ALLOW_THREADS {\r | |
141 | #define Py_BLOCK_THREADS\r | |
142 | #define Py_UNBLOCK_THREADS\r | |
143 | #define Py_END_ALLOW_THREADS }\r | |
144 | \r | |
145 | #endif /* !WITH_THREAD */\r | |
146 | \r | |
147 | PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);\r | |
148 | \r | |
149 | \r | |
150 | #ifdef __cplusplus\r | |
151 | }\r | |
152 | #endif\r | |
153 | #endif /* !Py_CEVAL_H */\r |