[pypy-svn] r73441 - pypy/branch/cpython-extension/pypy/module/cpyext
fijal at codespeak.net
fijal at codespeak.net
Tue Apr 6 05:40:02 CEST 2010
Author: fijal
Date: Tue Apr 6 05:40:00 2010
New Revision: 73441
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/api.py
pypy/branch/cpython-extension/pypy/module/cpyext/getargs.py
pypy/branch/cpython-extension/pypy/module/cpyext/misc.py
pypy/branch/cpython-extension/pypy/module/cpyext/modsupport.py
pypy/branch/cpython-extension/pypy/module/cpyext/stringobject.py
pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py
pypy/branch/cpython-extension/pypy/module/cpyext/typeobjectdefs.py
Log:
Some cleanups and refactorings - kill cpython_api_c and replace it with
register_c_function. I think now it's sort of pointless to have some files
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/api.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/api.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/api.py Tue Apr 6 05:40:00 2010
@@ -207,13 +207,11 @@
return unwrapper_raise # used in 'normal' RPython code.
return decorate
-def cpython_api_c():
- def decorate(func):
- def uncallable(*args, **kwds):
- raise Exception("Uncallable")
- FUNCTIONS_C[func.func_name] = None
- return uncallable
- return decorate
+def register_c_function(name):
+ """ Register a function implemented in C as a part of API
+ (not yet callable from RPython)
+ """
+ FUNCTIONS_C[name] = None
def cpython_struct(name, fields, forward=None):
configname = name.replace(' ', '__')
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/getargs.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/getargs.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/getargs.py Tue Apr 6 05:40:00 2010
@@ -1,55 +1,11 @@
from pypy.interpreter.error import OperationError
from pypy.module.cpyext.api import cpython_api, PyObject, CANNOT_FAIL, \
- VA_LIST_P, cpython_api_c
+ VA_LIST_P, register_c_function
from pypy.module.cpyext import api
from pypy.module.cpyext.pyobject import from_ref, make_ref,\
add_borrowed_object, register_container
from pypy.rpython.lltypesystem import lltype, rffi
- at cpython_api_c()
-def PyArg_Parse():
- pass
-
- at cpython_api_c()
-def PyArg_ParseTuple():
- pass
-
- at cpython_api_c()
-def PyArg_UnpackTuple():
- pass
-
- at cpython_api_c()
-def PyArg_ParseTupleAndKeywords():
- pass
-
- at cpython_api([PyObject, rffi.CCHARP, VA_LIST_P, rffi.INT_real],
- rffi.INT_real, error=0)
-def pypy_vgetargs1(space, w_obj, fmt, va_list_p, flags): #XXX unused, kill me, fijal?
- arg_i = 0
- fmt_i = 0
- while True:
- c = fmt[fmt_i]
- if c == "\x00":
- return 1
- elif c == "i":
- arr = api.va_get_int_star(va_list_p)
- arr[0] = rffi.cast(rffi.INT,
- space.int_w(space.getitem(w_obj, space.wrap(arg_i))))
- elif c == "O":
- w_item = space.getitem(w_obj, space.wrap(arg_i))
- if fmt[fmt_i + 1] == "!":
- fmt_i += 1
- w_type = from_ref(space, api.va_get_PyObject_star(va_list_p))
- if not space.is_true(space.isinstance(w_item, w_type)):
- raise OperationError(space.w_TypeError,
- space.wrap("wrong type"))
- arr = api.va_get_PyObject_star_star(va_list_p)
- arr[0] = make_ref(space, w_item, borrowed=True)
- register_container(space, w_obj)
- add_borrowed_object(space, arr[0])
- elif c == ':':
- return 1
- else:
- raise Exception("Unsupported parameter in vgetargs1: %s" % (c,))
- arg_i += 1
- fmt_i += 1
+for name in ['PyArg_Parse', 'PyArg_ParseTuple', 'PyArg_UnpackTuple',
+ 'PyArg_ParseTupleAndKeywords']:
+ register_c_function(name)
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/misc.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/misc.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/misc.py Tue Apr 6 05:40:00 2010
@@ -1,14 +1,5 @@
-from pypy.module.cpyext.api import cpython_api_c
+from pypy.module.cpyext.api import register_c_function
- at cpython_api_c()
-def Py_FatalError():
- pass
-
- at cpython_api_c()
-def PyOS_snprintf():
- pass
-
- at cpython_api_c()
-def PyOS_vsnprintf():
- pass
+for name in ['Py_FatalError', 'PyOS_snprintf', 'PyOS_vsnprintf']:
+ register_c_function(name)
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/modsupport.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/modsupport.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/modsupport.py Tue Apr 6 05:40:00 2010
@@ -1,19 +1,14 @@
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.module.cpyext.api import cpython_api, cpython_struct, \
- METH_STATIC, METH_CLASS, METH_COEXIST, CANNOT_FAIL, cpython_api_c
+ METH_STATIC, METH_CLASS, METH_COEXIST, CANNOT_FAIL, register_c_function
from pypy.module.cpyext.pyobject import PyObject, register_container
from pypy.interpreter.module import Module
from pypy.module.cpyext.methodobject import W_PyCFunctionObject, PyCFunction_NewEx, PyDescr_NewMethod, PyMethodDef, PyCFunction
from pypy.module.cpyext.pyerrors import PyErr_BadInternalCall
from pypy.interpreter.error import OperationError
- at cpython_api_c()
-def PyModule_AddObject():
- pass
-
- at cpython_api_c()
-def Py_BuildValue():
- pass
+for name in ['PyModule_AddObject', 'Py_BuildValue']:
+ register_c_function(name)
def PyImport_AddModule(space, name):
w_name = space.wrap(name)
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/stringobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/stringobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/stringobject.py Tue Apr 6 05:40:00 2010
@@ -3,7 +3,8 @@
from pypy.module.cpyext.api import (cpython_api, PyVarObjectFields,
PyStringObject, Py_ssize_t, cpython_struct,
CANNOT_FAIL, build_type_checkers,
- PyObjectP, cpython_api_c, PyTypeObjectPtr)
+ PyObjectP, PyTypeObjectPtr,
+ register_c_function)
from pypy.module.cpyext.pyobject import PyObject, make_ref, from_ref, Py_DecRef
@@ -20,9 +21,7 @@
py_str.c_ob_type = rffi.cast(PyTypeObjectPtr, make_ref(space, space.w_str))
return py_str
- at cpython_api_c()
-def PyString_FromFormatV():
- pass
+register_c_function('PyString_FromFormatV')
@cpython_api([rffi.CCHARP, Py_ssize_t], PyStringObject, error=lltype.nullptr(PyStringObject.TO))
def PyString_FromStringAndSize(space, char_p, length):
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py Tue Apr 6 05:40:00 2010
@@ -12,7 +12,7 @@
from pypy.objspace.std.typetype import _precheck_for_new
from pypy.objspace.std.objectobject import W_ObjectObject
from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.module.cpyext.api import cpython_api, cpython_api_c, cpython_struct, \
+from pypy.module.cpyext.api import cpython_api, cpython_struct, \
PyVarObjectFields, Py_ssize_t, Py_TPFLAGS_READYING, generic_cpy_call, \
Py_TPFLAGS_READY, Py_TPFLAGS_HEAPTYPE, PyStringObject, ADDR, \
Py_TPFLAGS_HAVE_CLASS, METH_VARARGS, METH_KEYWORDS, \
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/typeobjectdefs.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/typeobjectdefs.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/typeobjectdefs.py Tue Apr 6 05:40:00 2010
@@ -1,6 +1,6 @@
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.rpython.lltypesystem.lltype import Ptr, FuncType, Void
-from pypy.module.cpyext.api import cpython_api, cpython_api_c, cpython_struct, \
+from pypy.module.cpyext.api import cpython_struct, \
PyVarObjectFields, Py_ssize_t, Py_TPFLAGS_READYING, \
Py_TPFLAGS_READY, Py_TPFLAGS_HEAPTYPE, PyStringObject, ADDR, \
PyTypeObject, PyTypeObjectPtr
More information about the Pypy-commit
mailing list