4949class CallableIter :
5050 def __init__ (self , start ):
5151 self .idx = start
52-
52+
5353 def __call__ (self , * args ):
5454 cur = self .idx
5555 self .idx += 1
@@ -532,17 +532,17 @@ def _ref_hash_not_implemented(args):
532532 ),
533533 code = """
534534 #include <string.h>
535-
535+
536536 // CPython and other don't have this function; so define it
537537 #ifndef GRAALVM_PYTHON
538- #define _PyCFunction_GetMethodDef (OBJ) (((PyCFunctionObject*) (OBJ))->m_ml)
538+ #define GraalPyCFunction_GetMethodDef (OBJ) (((PyCFunctionObject*) (OBJ))->m_ml)
539539 #endif
540-
541- static PyObject* wrap_PyCFunction_GetMethodDef (PyObject* func) {
540+
541+ static PyObject* wrapGraalPyCFunction_GetMethodDef (PyObject* func) {
542542 PyMethodDef *src;
543543 PyMethodDef dst;
544544 if (PyCFunction_Check(func)) {
545- src = _PyCFunction_GetMethodDef (func);
545+ src = GraalPyCFunction_GetMethodDef (func);
546546 dst = *src;
547547 return PyUnicode_FromString(dst.ml_name);
548548 }
@@ -555,7 +555,7 @@ def _ref_hash_not_implemented(args):
555555 resultspec = "O" ,
556556 argspec = "O" ,
557557 arguments = ["PyObject* func" ],
558- callfunction = "wrap_PyCFunction_GetMethodDef " ,
558+ callfunction = "wrapGraalPyCFunction_GetMethodDef " ,
559559 cmpfunc = unhandled_error_compare
560560 )
561561 # create function from PyMethodDef
@@ -571,10 +571,10 @@ def test_PyMethodDef(self):
571571
572572 // CPython and other don't have this function; so define it
573573 #ifndef GRAALVM_PYTHON
574- #define _PyCFunction_GetMethodDef (OBJ) (((PyCFunctionObject*) (OBJ))->m_ml)
575- #define _PyCFunction_SetMethodDef (OBJ, VAL) (((PyCFunctionObject*) (OBJ))->m_ml = (VAL))
576- #define _PyCFunction_GetModule (OBJ) (((PyCFunctionObject*) (OBJ))->m_module)
577- #define _PyCFunction_SetModule (OBJ, VAL) (((PyCFunctionObject*) (OBJ))->m_module = (VAL))
574+ #define GraalPyCFunction_GetMethodDef (OBJ) (((PyCFunctionObject*) (OBJ))->m_ml)
575+ #define GraalPyCFunction_SetMethodDef (OBJ, VAL) (((PyCFunctionObject*) (OBJ))->m_ml = (VAL))
576+ #define GraalPyCFunction_GetModule (OBJ) (((PyCFunctionObject*) (OBJ))->m_module)
577+ #define GraalPyCFunction_SetModule (OBJ, VAL) (((PyCFunctionObject*) (OBJ))->m_module = (VAL))
578578 #define PyMethodDescrObject_GetMethod(OBJ) (((PyMethodDescrObject *) (OBJ))->d_method)
579579 #endif
580580
@@ -606,7 +606,7 @@ def test_PyMethodDef(self):
606606 PyErr_SetString(PyExc_TypeError, "<callable> is not a PyCFunction (i.e. builtin_method_or_function)");
607607 return NULL;
608608 }
609- PyMethodDef *def = _PyCFunction_GetMethodDef (arg);
609+ PyMethodDef *def = GraalPyCFunction_GetMethodDef (arg);
610610 return PyUnicode_FromString(def->ml_name);
611611 }
612612
@@ -615,7 +615,7 @@ def test_PyMethodDef(self):
615615 PyErr_SetString(PyExc_TypeError, "<callable> is not a PyCFunction (i.e. builtin_method_or_function)");
616616 return NULL;
617617 }
618- PyMethodDef *def = _PyCFunction_GetMethodDef (arg);
618+ PyMethodDef *def = GraalPyCFunction_GetMethodDef (arg);
619619 return PyLong_FromLong(def->ml_flags);
620620 }
621621
@@ -675,7 +675,7 @@ def test_PyMethodDef(self):
675675 return NULL;
676676 }
677677 }
678-
678+
679679 static PyObject *call_meth(PyObject *self, PyObject *args) {
680680 PyObject *callable, *callable_args, *callable_kwargs = NULL;
681681 if (!PyArg_ParseTuple(args, "OO|O:call_meth",
@@ -687,7 +687,7 @@ def test_PyMethodDef(self):
687687 PyErr_SetString(PyExc_TypeError, "<callable> is not a PyCFunction (i.e. builtin_method_or_function) ");
688688 return NULL;
689689 }
690- PyMethodDef *def = _PyCFunction_GetMethodDef (callable);
690+ PyMethodDef *def = GraalPyCFunction_GetMethodDef (callable);
691691 // returns a borrowed ref
692692 PyObject *callable_self = PyCFunction_GetSelf(callable);
693693 return _call_PyCFunction(def, callable_self, callable_args, callable_kwargs);
@@ -714,7 +714,7 @@ def test_PyMethodDef(self):
714714 PyErr_SetString(PyExc_TypeError, "<callable> is not a PyCFunction (i.e. builtin_method_or_function)");
715715 return NULL;
716716 }
717- PyMethodDef *def = _PyCFunction_GetMethodDef (arg);
717+ PyMethodDef *def = GraalPyCFunction_GetMethodDef (arg);
718718 return PyUnicode_FromString(def->ml_doc);
719719 }
720720
@@ -723,20 +723,20 @@ def test_PyMethodDef(self):
723723 PyErr_SetString(PyExc_TypeError, "<callable> is not a PyCFunction (i.e. builtin_method_or_function)");
724724 return NULL;
725725 }
726- PyMethodDef *def = _PyCFunction_GetMethodDef (arg);
727- _PyCFunction_SetMethodDef (arg, def);
728- return PyUnicode_FromString(_PyCFunction_GetMethodDef (arg)->ml_doc);
726+ PyMethodDef *def = GraalPyCFunction_GetMethodDef (arg);
727+ GraalPyCFunction_SetMethodDef (arg, def);
728+ return PyUnicode_FromString(GraalPyCFunction_GetMethodDef (arg)->ml_doc);
729729 }
730730
731731 static PyObject *get_set_module(PyObject *self, PyObject *arg) {
732732 if (!PyCFunction_Check(arg)) {
733733 PyErr_SetString(PyExc_TypeError, "<callable> is not a PyCFunction (i.e. builtin_method_or_function)");
734734 return NULL;
735735 }
736- PyObject *module = _PyCFunction_GetModule (arg);
736+ PyObject *module = GraalPyCFunction_GetModule (arg);
737737 Py_XINCREF(self);
738- _PyCFunction_SetModule (arg, self);
739- if (_PyCFunction_GetModule (arg) != self) {
738+ GraalPyCFunction_SetModule (arg, self);
739+ if (GraalPyCFunction_GetModule (arg) != self) {
740740 PyErr_SetString(PyExc_TypeError, "module of function is not self");
741741 return NULL;
742742 }
@@ -754,7 +754,7 @@ def test_PyMethodDef(self):
754754 }
755755 PyMethodDef *def;
756756 if (PyCFunction_Check(callable)) {
757- def = _PyCFunction_GetMethodDef (callable);
757+ def = GraalPyCFunction_GetMethodDef (callable);
758758 } else if (PyObject_TypeCheck(callable, &PyMethodDescr_Type)) {
759759 def = PyMethodDescrObject_GetMethod(callable);
760760 } else {
0 commit comments