1414/******** Unary functions ********/
1515
1616static PyObject *
17- no_intrinsic (PyThreadState * tstate , PyObject * unused )
17+ no_intrinsic1 (PyThreadState * tstate , PyObject * unused )
1818{
1919 _PyErr_SetString (tstate , PyExc_SystemError , "invalid intrinsic function" );
2020 return NULL ;
@@ -203,25 +203,35 @@ make_typevar(PyThreadState* Py_UNUSED(ignored), PyObject *v)
203203 return _Py_make_typevar (v , NULL , NULL );
204204}
205205
206- const instrinsic_func1
206+
207+ #define INTRINSIC_FUNC_ENTRY (N , F ) \
208+ [N] = {F, #N},
209+
210+ const intrinsic_func1_info
207211_PyIntrinsics_UnaryFunctions [] = {
208- [ 0 ] = no_intrinsic ,
209- [ INTRINSIC_PRINT ] = print_expr ,
210- [ INTRINSIC_IMPORT_STAR ] = import_star ,
211- [ INTRINSIC_STOPITERATION_ERROR ] = stopiteration_error ,
212- [ INTRINSIC_ASYNC_GEN_WRAP ] = _PyAsyncGenValueWrapperNew ,
213- [ INTRINSIC_UNARY_POSITIVE ] = unary_pos ,
214- [ INTRINSIC_LIST_TO_TUPLE ] = list_to_tuple ,
215- [ INTRINSIC_TYPEVAR ] = make_typevar ,
216- [ INTRINSIC_PARAMSPEC ] = _Py_make_paramspec ,
217- [ INTRINSIC_TYPEVARTUPLE ] = _Py_make_typevartuple ,
218- [ INTRINSIC_SUBSCRIPT_GENERIC ] = _Py_subscript_generic ,
219- [ INTRINSIC_TYPEALIAS ] = _Py_make_typealias ,
212+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_1_INVALID , no_intrinsic1 )
213+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_PRINT , print_expr )
214+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_IMPORT_STAR , import_star )
215+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_STOPITERATION_ERROR , stopiteration_error )
216+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_ASYNC_GEN_WRAP , _PyAsyncGenValueWrapperNew )
217+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_UNARY_POSITIVE , unary_pos )
218+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_LIST_TO_TUPLE , list_to_tuple )
219+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_TYPEVAR , make_typevar )
220+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_PARAMSPEC , _Py_make_paramspec )
221+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_TYPEVARTUPLE , _Py_make_typevartuple )
222+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_SUBSCRIPT_GENERIC , _Py_subscript_generic )
223+ INTRINSIC_FUNC_ENTRY ( INTRINSIC_TYPEALIAS , _Py_make_typealias )
220224};
221225
222226
223227/******** Binary functions ********/
224228
229+ static PyObject *
230+ no_intrinsic2 (PyThreadState * tstate , PyObject * unused1 , PyObject * unused2 )
231+ {
232+ _PyErr_SetString (tstate , PyExc_SystemError , "invalid intrinsic function" );
233+ return NULL ;
234+ }
225235
226236static PyObject *
227237prep_reraise_star (PyThreadState * unused , PyObject * orig , PyObject * excs )
@@ -246,10 +256,31 @@ make_typevar_with_constraints(PyThreadState* Py_UNUSED(ignored), PyObject *name,
246256 return _Py_make_typevar (name , NULL , evaluate_constraints );
247257}
248258
249- const instrinsic_func2
259+ const intrinsic_func2_info
250260_PyIntrinsics_BinaryFunctions [] = {
251- [INTRINSIC_PREP_RERAISE_STAR ] = prep_reraise_star ,
252- [INTRINSIC_TYPEVAR_WITH_BOUND ] = make_typevar_with_bound ,
253- [INTRINSIC_TYPEVAR_WITH_CONSTRAINTS ] = make_typevar_with_constraints ,
254- [INTRINSIC_SET_FUNCTION_TYPE_PARAMS ] = _Py_set_function_type_params ,
261+ INTRINSIC_FUNC_ENTRY (INTRINSIC_2_INVALID , no_intrinsic2 )
262+ INTRINSIC_FUNC_ENTRY (INTRINSIC_PREP_RERAISE_STAR , prep_reraise_star )
263+ INTRINSIC_FUNC_ENTRY (INTRINSIC_TYPEVAR_WITH_BOUND , make_typevar_with_bound )
264+ INTRINSIC_FUNC_ENTRY (INTRINSIC_TYPEVAR_WITH_CONSTRAINTS , make_typevar_with_constraints )
265+ INTRINSIC_FUNC_ENTRY (INTRINSIC_SET_FUNCTION_TYPE_PARAMS , _Py_set_function_type_params )
255266};
267+
268+ #undef INTRINSIC_FUNC_ENTRY
269+
270+ PyObject *
271+ _PyUnstable_GetUnaryIntrinsicName (int index )
272+ {
273+ if (index < 0 || index > MAX_INTRINSIC_1 ) {
274+ return NULL ;
275+ }
276+ return PyUnicode_FromString (_PyIntrinsics_UnaryFunctions [index ].name );
277+ }
278+
279+ PyObject *
280+ _PyUnstable_GetBinaryIntrinsicName (int index )
281+ {
282+ if (index < 0 || index > MAX_INTRINSIC_2 ) {
283+ return NULL ;
284+ }
285+ return PyUnicode_FromString (_PyIntrinsics_BinaryFunctions [index ].name );
286+ }
0 commit comments