Author: Armin Rigo <[email protected]>
Branch:
Changeset: r68363:cd3b6b2b06fd
Date: 2013-12-02 20:31 +0000
http://bitbucket.org/pypy/pypy/changeset/cd3b6b2b06fd/
Log: Systematically rename the C API functions of cpyext, from PyXxx to
PyPyXxx. Fix some details that are unhappy about the new macros.
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -400,16 +400,16 @@
'_PyObject_CallFunction_SizeT', '_PyObject_CallMethod_SizeT',
'PyBuffer_FromMemory', 'PyBuffer_FromReadWriteMemory',
'PyBuffer_FromObject',
- 'PyBuffer_FromReadWriteObject', 'PyBuffer_New', 'PyBuffer_Type',
'init_bufferobject',
+ 'PyBuffer_FromReadWriteObject', 'PyBuffer_New', 'PyBuffer_Type',
'_Py_init_bufferobject',
'PyCObject_FromVoidPtr', 'PyCObject_FromVoidPtrAndDesc',
'PyCObject_AsVoidPtr',
'PyCObject_GetDesc', 'PyCObject_Import', 'PyCObject_SetVoidPtr',
- 'PyCObject_Type', 'init_pycobject',
+ 'PyCObject_Type', '_Py_init_pycobject',
'PyCapsule_New', 'PyCapsule_IsValid', 'PyCapsule_GetPointer',
'PyCapsule_GetName', 'PyCapsule_GetDestructor', 'PyCapsule_GetContext',
'PyCapsule_SetPointer', 'PyCapsule_SetName', 'PyCapsule_SetDestructor',
- 'PyCapsule_SetContext', 'PyCapsule_Import', 'PyCapsule_Type',
'init_capsule',
+ 'PyCapsule_SetContext', 'PyCapsule_Import', 'PyCapsule_Type',
'_Py_init_capsule',
'PyObject_AsReadBuffer', 'PyObject_AsWriteBuffer',
'PyObject_CheckReadBuffer',
@@ -687,11 +687,11 @@
globals()['va_get_%s' % name_no_star] = func
def setup_init_functions(eci, translating):
- init_buffer = rffi.llexternal('init_bufferobject', [], lltype.Void,
+ init_buffer = rffi.llexternal('_PyPy_init_bufferobject', [], lltype.Void,
compilation_info=eci, _nowrapper=True)
- init_pycobject = rffi.llexternal('init_pycobject', [], lltype.Void,
+ init_pycobject = rffi.llexternal('_PyPy_init_pycobject', [], lltype.Void,
compilation_info=eci, _nowrapper=True)
- init_capsule = rffi.llexternal('init_capsule', [], lltype.Void,
+ init_capsule = rffi.llexternal('_PyPy_init_capsule', [], lltype.Void,
compilation_info=eci, _nowrapper=True)
INIT_FUNCTIONS.extend([
lambda space: init_buffer(),
@@ -871,6 +871,7 @@
continue
name = name.replace("#", "")
newname = name.replace('Py', 'PyPy')
+ assert newname != name
if not rename:
newname = name
pypy_macros.append('#define %s %s' % (name, newname))
@@ -1041,7 +1042,7 @@
from rpython.translator.c.database import LowLevelDatabase
db = LowLevelDatabase()
- generate_macros(export_symbols, rename=False, do_deref=False)
+ generate_macros(export_symbols, rename=True, do_deref=False)
functions = generate_decls_and_callbacks(db, [], api_struct=False)
code = "#include <Python.h>\n" + "\n".join(functions)
diff --git a/pypy/module/cpyext/include/bufferobject.h
b/pypy/module/cpyext/include/bufferobject.h
--- a/pypy/module/cpyext/include/bufferobject.h
+++ b/pypy/module/cpyext/include/bufferobject.h
@@ -37,7 +37,7 @@
PyObject* PyBuffer_New(Py_ssize_t size);
-void init_bufferobject(void);
+void _Py_init_bufferobject(void);
#ifdef __cplusplus
}
diff --git a/pypy/module/cpyext/include/pycapsule.h
b/pypy/module/cpyext/include/pycapsule.h
--- a/pypy/module/cpyext/include/pycapsule.h
+++ b/pypy/module/cpyext/include/pycapsule.h
@@ -50,7 +50,7 @@
PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block);
-void init_capsule(void);
+void _Py_init_capsule(void);
#ifdef __cplusplus
}
diff --git a/pypy/module/cpyext/include/pycobject.h
b/pypy/module/cpyext/include/pycobject.h
--- a/pypy/module/cpyext/include/pycobject.h
+++ b/pypy/module/cpyext/include/pycobject.h
@@ -48,7 +48,7 @@
} PyCObject;
#endif
-void init_pycobject(void);
+void _Py_init_pycobject(void);
#ifdef __cplusplus
}
diff --git a/pypy/module/cpyext/src/bufferobject.c
b/pypy/module/cpyext/src/bufferobject.c
--- a/pypy/module/cpyext/src/bufferobject.c
+++ b/pypy/module/cpyext/src/bufferobject.c
@@ -783,7 +783,7 @@
return size;
}
-void init_bufferobject(void)
+void _Py_init_bufferobject(void)
{
PyType_Ready(&PyBuffer_Type);
}
diff --git a/pypy/module/cpyext/src/capsule.c b/pypy/module/cpyext/src/capsule.c
--- a/pypy/module/cpyext/src/capsule.c
+++ b/pypy/module/cpyext/src/capsule.c
@@ -321,7 +321,7 @@
PyCapsule_Type__doc__ /*tp_doc*/
};
-void init_capsule()
+void _Py_init_capsule()
{
PyType_Ready(&PyCapsule_Type);
}
diff --git a/pypy/module/cpyext/src/cobject.c b/pypy/module/cpyext/src/cobject.c
--- a/pypy/module/cpyext/src/cobject.c
+++ b/pypy/module/cpyext/src/cobject.c
@@ -156,7 +156,7 @@
PyCObject_Type__doc__ /*tp_doc*/
};
-void init_pycobject()
+void _Py_init_pycobject()
{
PyType_Ready(&PyCObject_Type);
}
diff --git a/rpython/translator/c/src/exception.h
b/rpython/translator/c/src/exception.h
--- a/rpython/translator/c/src/exception.h
+++ b/rpython/translator/c/src/exception.h
@@ -36,7 +36,6 @@
/* prototypes */
-#define RPyRaiseSimpleException(exc, msg) _RPyRaiseSimpleException(R##exc)
void _RPyRaiseSimpleException(RPYTHON_EXCEPTION rexc);
#endif
diff --git a/rpython/translator/c/src/support.h
b/rpython/translator/c/src/support.h
--- a/rpython/translator/c/src/support.h
+++ b/rpython/translator/c/src/support.h
@@ -5,13 +5,9 @@
#define RUNNING_ON_LLINTERP 0
#define OP_JIT_RECORD_KNOWN_CLASS(i, c, r) /* nothing */
-#define FAIL_EXCEPTION(exc, msg) \
- { \
- RPyRaiseSimpleException(exc, msg); \
- }
-#define FAIL_OVF(msg) FAIL_EXCEPTION(PyExc_OverflowError, msg)
-#define FAIL_VAL(msg) FAIL_EXCEPTION(PyExc_ValueError, msg)
-#define FAIL_ZER(msg) FAIL_EXCEPTION(PyExc_ZeroDivisionError, msg)
+#define FAIL_OVF(msg) _RPyRaiseSimpleException(RPyExc_OverflowError)
+#define FAIL_VAL(msg) _RPyRaiseSimpleException(RPyExc_ValueError)
+#define FAIL_ZER(msg) _RPyRaiseSimpleException(RPyExc_ZeroDivisionError)
/* Extra checks can be enabled with the RPY_ASSERT or RPY_LL_ASSERT
* macros. They differ in the level at which the tests are made.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit