|
64 | 64 | @CApiExternalFunctionSignatures |
65 | 65 | public enum ExternalFunctionSignature implements NativeCExtSymbol { |
66 | 66 | // typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); |
67 | | - PYCFUNCTION(PyObjectReturn, PyObject, PyObject), |
| 67 | + PYCFUNCTION(false, PyObjectReturn, PyObject, PyObject), |
68 | 68 | // typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, PyObject *); |
69 | | - PYCFUNCTION_WITH_KEYWORDS(PyObjectReturn, PyObject, PyObject, PyObject), |
| 69 | + PYCFUNCTION_WITH_KEYWORDS(false, PyObjectReturn, PyObject, PyObject, PyObject), |
70 | 70 | // typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject *const *, Py_ssize_t); |
71 | | - PYCFUNCTION_FAST(PyObjectReturn, PyObject, Pointer, Py_ssize_t), |
| 71 | + PYCFUNCTION_FAST(false, PyObjectReturn, PyObject, Pointer, Py_ssize_t), |
72 | 72 | // typedef PyObject *(*_PyCFunctionFastWithKeywords) (PyObject *, PyObject *const *, Py_ssize_t, |
73 | 73 | // PyObject *); |
74 | | - PYCFUNCTION_FAST_WITH_KEYWORDS(PyObjectReturn, PyObject, Pointer, Py_ssize_t, PyObject), |
| 74 | + PYCFUNCTION_FAST_WITH_KEYWORDS(false, PyObjectReturn, PyObject, Pointer, Py_ssize_t, PyObject), |
75 | 75 | // typedef PyObject *(*PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, |
76 | 76 | // PyObject *); |
77 | | - PYCMETHOD(PyObjectReturn, PyObject, PyTypeObject, Pointer, Py_ssize_t, PyObject), |
| 77 | + PYCMETHOD(false, PyObjectReturn, PyObject, PyTypeObject, Pointer, Py_ssize_t, PyObject), |
78 | 78 |
|
79 | 79 | // typedef PyObject * (*unaryfunc)(PyObject *); |
80 | | - UNARYFUNC(PyObjectReturn, PyObject), |
| 80 | + UNARYFUNC(false, PyObjectReturn, PyObject), |
81 | 81 | // typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); |
82 | | - BINARYFUNC(PyObjectReturn, PyObject, PyObject), |
| 82 | + BINARYFUNC(false, PyObjectReturn, PyObject, PyObject), |
83 | 83 | // typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); |
84 | | - TERNARYFUNC(PyObjectReturn, PyObject, PyObject, PyObject), |
| 84 | + TERNARYFUNC(false, PyObjectReturn, PyObject, PyObject, PyObject), |
85 | 85 | // typedef int (*inquiry)(PyObject *); |
86 | | - INQUIRY(Int, PyObject), |
| 86 | + INQUIRY(false, Int, PyObject), |
87 | 87 | // typedef Py_ssize_t (*lenfunc)(PyObject *); |
88 | | - LENFUNC(PrimitiveResult64, PyObject), |
| 88 | + LENFUNC(false, PrimitiveResult64, PyObject), |
89 | 89 | // typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t); |
90 | | - SSIZEARGFUNC(PyObjectReturn, PyObject, Py_ssize_t), |
| 90 | + SSIZEARGFUNC(false, PyObjectReturn, PyObject, Py_ssize_t), |
91 | 91 |
|
92 | 92 | // typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t); |
93 | | - SSIZESSIZEARGFUNC(PyObjectReturn, PyObject, Py_ssize_t, Py_ssize_t), |
| 93 | + SSIZESSIZEARGFUNC(false, PyObjectReturn, PyObject, Py_ssize_t, Py_ssize_t), |
94 | 94 | // typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *); |
95 | | - SSIZEOBJARGPROC(Int, PyObject, Py_ssize_t, PyObject), |
| 95 | + SSIZEOBJARGPROC(false, Int, PyObject, Py_ssize_t, PyObject), |
96 | 96 | // typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); |
97 | | - SSIZESSIZEOBJARGPROC(Int, PyObject, Py_ssize_t, Py_ssize_t, PyObject), |
| 97 | + SSIZESSIZEOBJARGPROC(false, Int, PyObject, Py_ssize_t, Py_ssize_t, PyObject), |
98 | 98 | // typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *); |
99 | | - OBJOBJARGPROC(Int, PyObject, PyObject, PyObject), |
| 99 | + OBJOBJARGPROC(false, Int, PyObject, PyObject, PyObject), |
100 | 100 |
|
101 | 101 | // typedef int (*objobjproc)(PyObject *, PyObject *); |
102 | | - OBJOBJPROC(Int, PyObject, PyObject), |
| 102 | + OBJOBJPROC(false, Int, PyObject, PyObject), |
103 | 103 | // typedef int (*visitproc)(PyObject *, void *); |
104 | | - VISITPROC(Int, PyObject, Pointer), |
| 104 | + VISITPROC(false, Int, PyObject, Pointer), |
105 | 105 | // typedef int (*traverseproc)(PyObject *, visitproc, void *); |
106 | | - TRAVERSEPROC(Int, PyObject, Pointer, Pointer), |
| 106 | + TRAVERSEPROC(false, Int, PyObject, Pointer, Pointer), |
107 | 107 | // PyObject *PyType_GenericAlloc(PyTypeObject *, Py_ssize_t); |
108 | | - TYPE_GENERIC_ALLOC(PyObjectReturn, PyTypeObject, Py_ssize_t), |
| 108 | + TYPE_GENERIC_ALLOC(false, PyObjectReturn, PyTypeObject, Py_ssize_t), |
109 | 109 |
|
110 | 110 | // typedef void (*freefunc)(void *); |
111 | | - FREEFUNC(Void, Pointer), |
| 111 | + FREEFUNC(false, Void, Pointer), |
112 | 112 | // typedef void (*destructor)(PyObject *); |
113 | | - DESTRUCTOR(Void, PyObject), |
| 113 | + DESTRUCTOR(false, Void, PyObject), |
114 | 114 | // void _Py_Dealloc(PyObject *); |
115 | | - PY_DEALLOC(Void, PyObject), |
| 115 | + PY_DEALLOC(false, Void, PyObject), |
116 | 116 | // typedef PyObject *(*getattrfunc)(PyObject *, char *); |
117 | | - GETATTRFUNC(PyObjectReturn, PyObject, CharPtrAsTruffleString), |
| 117 | + GETATTRFUNC(false, PyObjectReturn, PyObject, CharPtrAsTruffleString), |
118 | 118 | // typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); |
119 | | - GETATTROFUNC(PyObjectReturn, PyObject, PyObject), |
| 119 | + GETATTROFUNC(false, PyObjectReturn, PyObject, PyObject), |
120 | 120 | // typedef int (*setattrfunc)(PyObject *, char *, PyObject *); |
121 | | - SETATTRFUNC(Int, PyObject, CharPtrAsTruffleString, PyObject), |
| 121 | + SETATTRFUNC(false, Int, PyObject, CharPtrAsTruffleString, PyObject), |
122 | 122 | // typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); |
123 | | - SETATTROFUNC(Int, PyObject, PyObject, PyObject), |
| 123 | + SETATTROFUNC(false, Int, PyObject, PyObject, PyObject), |
124 | 124 | // typedef PyObject *(*reprfunc)(PyObject *); |
125 | | - REPRFUNC(PyObjectReturn, PyObject), |
| 125 | + REPRFUNC(false, PyObjectReturn, PyObject), |
126 | 126 | // typedef Py_hash_t (*hashfunc)(PyObject *); |
127 | | - HASHFUNC(Py_ssize_t, PyObject), |
| 127 | + HASHFUNC(false, Py_ssize_t, PyObject), |
128 | 128 | // typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); |
129 | | - RICHCMPFUNC(PyObjectReturn, PyObject, PyObject, Int), |
| 129 | + RICHCMPFUNC(false, PyObjectReturn, PyObject, PyObject, Int), |
130 | 130 | // typedef PyObject *(*getiterfunc) (PyObject *); |
131 | | - GETITERFUNC(PyObjectReturn, PyObject), |
| 131 | + GETITERFUNC(false, PyObjectReturn, PyObject), |
132 | 132 | // typedef PyObject *(*iternextfunc) (PyObject *); |
133 | | - ITERNEXTFUNC(PyObjectReturn, PyObject), |
| 133 | + ITERNEXTFUNC(false, PyObjectReturn, PyObject), |
134 | 134 | // typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); |
135 | | - DESCRGETFUNC(PyObjectReturn, PyObject, PyObject, PyObject), |
| 135 | + DESCRGETFUNC(false, PyObjectReturn, PyObject, PyObject, PyObject), |
136 | 136 | // typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); |
137 | | - DESCRSETFUNC(Int, PyObject, PyObject, PyObject), |
| 137 | + DESCRSETFUNC(false, Int, PyObject, PyObject, PyObject), |
138 | 138 | // typedef int (*initproc)(PyObject *, PyObject *, PyObject *); |
139 | | - INITPROC(Int, PyObject, PyObject, PyObject), |
| 139 | + INITPROC(false, Int, PyObject, PyObject, PyObject), |
140 | 140 | // typedef PyObject *(*newfunc)(PyTypeObject *, PyObject *, PyObject *); |
141 | | - NEWFUNC(PyObjectReturn, PyTypeObject, PyObject, PyObject), |
| 141 | + NEWFUNC(false, PyObjectReturn, PyTypeObject, PyObject, PyObject), |
142 | 142 |
|
143 | 143 | // typedef PyObject *(*getter)(PyObject *, void *); |
144 | | - GETTER(PyObjectReturn, PyObject, Pointer), |
| 144 | + GETTER(false, PyObjectReturn, PyObject, Pointer), |
145 | 145 | // typedef int (*setter)(PyObject *, PyObject *, void *); |
146 | | - SETTER(Int, PyObject, PyObject, Pointer), |
| 146 | + SETTER(false, Int, PyObject, PyObject, Pointer), |
147 | 147 | // typedef PyObject *(*Py_mod_create)(PyObject *, PyModuleDef *); |
148 | | - MODCREATE(PyObjectReturn, Pointer, Pointer), |
| 148 | + MODCREATE(false, PyObjectReturn, Pointer, Pointer), |
149 | 149 | // typedef int (*Py_mod_exec)(PyObject *); |
150 | | - MODEXEC(Int, Pointer), |
| 150 | + MODEXEC(false, Int, Pointer), |
151 | 151 | // typedef PyObject *(*PyInit_mod)(void); |
152 | | - MODINIT(Pointer), |
153 | | - // typedef void (*initialize_graal_capi)(void *, void *, void *, void *); |
154 | | - CAPIINIT(Void, Pointer, Pointer, Pointer, Pointer), |
| 152 | + MODINIT(false, Pointer), |
| 153 | + // typedef PThreadState** (*initialize_graal_capi)(void *, void *, void *, void *); |
| 154 | + CAPIINIT(false, Pointer, Pointer, Pointer, Pointer, Pointer), |
155 | 155 | // typedef void *(*GraalPyPrivate_GetFinalizeCApiPointer)(void); |
156 | | - GETFINALIZECAPIPOINTER(Pointer), |
| 156 | + GETFINALIZECAPIPOINTER(false, Pointer), |
157 | 157 |
|
158 | 158 | // TODO(fa): should be an implicit signature |
159 | | - GCCOLLECT(Py_ssize_t, Int); |
| 159 | + GCCOLLECT(false, Py_ssize_t, Int), |
| 160 | + GETDICTPTRFUN(true, Pointer, PyObject); |
160 | 161 |
|
161 | 162 | public final ArgDescriptor returnValue; |
162 | 163 | public final ArgDescriptor[] arguments; |
163 | 164 |
|
164 | | - ExternalFunctionSignature(ArgDescriptor returnValue, ArgDescriptor... arguments) { |
| 165 | + /** |
| 166 | + * If {@code true}, the function will be called without a call boundary (see |
| 167 | + * {@link com.oracle.graal.python.runtime.ExecutionContext.BoundaryCallContext}). Hence, the |
| 168 | + * native function must not raise Python exception. |
| 169 | + */ |
| 170 | + public final boolean cannotRaise; |
| 171 | + |
| 172 | + ExternalFunctionSignature(boolean cannotRaise, ArgDescriptor returnValue, ArgDescriptor... arguments) { |
| 173 | + this.cannotRaise = cannotRaise; |
165 | 174 | this.returnValue = returnValue; |
166 | 175 | this.arguments = arguments; |
167 | 176 | } |
|
0 commit comments