[pypy-svn] r72484 - in pypy/trunk/pypy/module/cpyext: . include
xoraxax at codespeak.net
xoraxax at codespeak.net
Sun Mar 21 01:18:52 CET 2010
Author: xoraxax
Date: Sun Mar 21 01:18:50 2010
New Revision: 72484
Added:
pypy/trunk/pypy/module/cpyext/dictobject.py (contents, props changed)
pypy/trunk/pypy/module/cpyext/include/dictobject.h (contents, props changed)
pypy/trunk/pypy/module/cpyext/include/macros.h (contents, props changed)
pypy/trunk/pypy/module/cpyext/include/tupleobject.h (contents, props changed)
pypy/trunk/pypy/module/cpyext/include/varargwrapper.c (contents, props changed)
pypy/trunk/pypy/module/cpyext/tupleobject.py (contents, props changed)
Modified:
pypy/trunk/pypy/module/cpyext/__init__.py
pypy/trunk/pypy/module/cpyext/api.py
pypy/trunk/pypy/module/cpyext/include/Python.h
pypy/trunk/pypy/module/cpyext/include/object.h
pypy/trunk/pypy/module/cpyext/include/typeobject.c
pypy/trunk/pypy/module/cpyext/macros.py
Log:
General progress.
Modified: pypy/trunk/pypy/module/cpyext/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/__init__.py (original)
+++ pypy/trunk/pypy/module/cpyext/__init__.py Sun Mar 21 01:18:50 2010
@@ -34,4 +34,6 @@
import pypy.module.cpyext.pyerrors
import pypy.module.cpyext.typeobject
import pypy.module.cpyext.object
+import pypy.module.cpyext.tupleobject
+import pypy.module.cpyext.dictobject
api.configure()
Modified: pypy/trunk/pypy/module/cpyext/api.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/api.py (original)
+++ pypy/trunk/pypy/module/cpyext/api.py Sun Mar 21 01:18:50 2010
@@ -181,6 +181,7 @@
PyObject *PyPy_False = NULL;
PyObject *PyPyExc_Exception = NULL;
PyTypeObject *PyPyType_Type = NULL;
+ PyTypeObject *PyPyBaseObject_Type = NULL;
"""
code = (prologue +
struct_declaration_code +
@@ -192,7 +193,8 @@
eci = ExternalCompilationInfo(
include_dirs=include_dirs,
separate_module_sources=[code],
- #separate_module_files=[include_dir / "typeobject.c"],
+ #separate_module_files=[include_dir / "typeobject.c",
+ # include_dir / "varargwrapper.c"],
export_symbols=['pypyAPI'] + export_symbols,
)
eci = eci.convert_sources_to_files()
@@ -210,7 +212,9 @@
("PyPy_True", space.w_True),
("PyPy_False", space.w_False),
("PyPyExc_Exception", space.w_Exception),
- ("PyPyType_Type", space.w_type)]:
+ ("PyPyType_Type", space.w_type),
+ ("PyPyBaseObject_Type", space.w_object),
+ ]:
ptr = ctypes.c_void_p.in_dll(bridge, name)
ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(make_ref(space, w_obj)),
ctypes.c_void_p).value
Added: pypy/trunk/pypy/module/cpyext/dictobject.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/module/cpyext/dictobject.py Sun Mar 21 01:18:50 2010
@@ -0,0 +1,4 @@
+from pypy.rpython.lltypesystem import rffi, lltype
+from pypy.module.cpyext.api import cpython_api, PyObject
+
+
Modified: pypy/trunk/pypy/module/cpyext/include/Python.h
==============================================================================
--- pypy/trunk/pypy/module/cpyext/include/Python.h (original)
+++ pypy/trunk/pypy/module/cpyext/include/Python.h Sun Mar 21 01:18:50 2010
@@ -1,13 +1,15 @@
#ifndef Py_PYTHON_H
#define Py_PYTHON_H
+/* Compat stuff */
#include <inttypes.h>
#include <stdint.h>
-typedef long Py_ssize_t;
+#define Py_ssize_t long
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
#include "object.h"
+/* move somewhere else */
extern PyObject *PyPy_None;
#define Py_None PyPy_None
@@ -24,5 +26,8 @@
#include "pyerrors.h"
#include "stringobject.h"
#include "descrobject.h"
+#include "tupleobject.h"
+#include "dictobject.h"
+#include "macros.h"
#endif
Added: pypy/trunk/pypy/module/cpyext/include/dictobject.h
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/module/cpyext/include/dictobject.h Sun Mar 21 01:18:50 2010
@@ -0,0 +1,14 @@
+
+/* dict object interface */
+
+#ifndef Py_DICTOBJECT_H
+#define Py_DICTOBJECT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_DICTOBJECT_H */
Added: pypy/trunk/pypy/module/cpyext/include/macros.h
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/module/cpyext/include/macros.h Sun Mar 21 01:18:50 2010
@@ -0,0 +1,3 @@
+/* operate on PyObject* */
+void Py_INCREF(PyObject *);
+void Py_DECREF(PyObject *);
Modified: pypy/trunk/pypy/module/cpyext/include/object.h
==============================================================================
--- pypy/trunk/pypy/module/cpyext/include/object.h (original)
+++ pypy/trunk/pypy/module/cpyext/include/object.h Sun Mar 21 01:18:50 2010
@@ -380,6 +380,8 @@
extern PyTypeObject *PyPyType_Type; /* built-in 'type' */
#define PyType_Type *PyPyType_Type
+extern PyTypeObject *PyPyBaseObject_Type;
+#define PyBaseObject_Type *PyPyBaseObject_Type
int PyPyType_Ready(PyTypeObject *);
#define PyType_Ready PyPyType_Ready
Added: pypy/trunk/pypy/module/cpyext/include/tupleobject.h
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/module/cpyext/include/tupleobject.h Sun Mar 21 01:18:50 2010
@@ -0,0 +1,16 @@
+
+/* Tuple object interface */
+
+#ifndef Py_TUPLEOBJECT_H
+#define Py_TUPLEOBJECT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+PyObject * PyTuple_New(Py_ssize_t size);
+PyObject * PyTuple_Pack(Py_ssize_t, ...);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_TUPLEOBJECT_H */
Modified: pypy/trunk/pypy/module/cpyext/include/typeobject.c
==============================================================================
--- pypy/trunk/pypy/module/cpyext/include/typeobject.c (original)
+++ pypy/trunk/pypy/module/cpyext/include/typeobject.c Sun Mar 21 01:18:50 2010
@@ -1,6 +1,9 @@
+#include <assert.h>
+
#include <pypy_rename.h>
#include <Python.h>
+
int
PyPyType_Ready(PyTypeObject *type)
{
Added: pypy/trunk/pypy/module/cpyext/include/varargwrapper.c
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/module/cpyext/include/varargwrapper.c Sun Mar 21 01:18:50 2010
@@ -0,0 +1,20 @@
+#include <pypy_rename.h>
+#include <Python.h>
+#include <stdarg.h>
+
+PyObject * PyTuple_Pack(Py_ssize_t size, ...)
+{
+ va_list ap;
+ PyObject *cur, *tuple;
+ int i;
+
+ tuple = PyTuple_New(size);
+ va_start(ap, size);
+ for (i = 0; i < size; cur = va_arg(ap, PyObject*)) {
+ Py_INCREF(cur);
+ PyTuple_SetItem(tuple, i, cur);
+ }
+ va_end(ap);
+ return tuple;
+}
+
Modified: pypy/trunk/pypy/module/cpyext/macros.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/macros.py (original)
+++ pypy/trunk/pypy/module/cpyext/macros.py Sun Mar 21 01:18:50 2010
@@ -25,4 +25,3 @@
state = space.fromcache(State)
obj = state.py_objects_w2r.get(w_obj)
obj.c_obj_refcnt += 1
- return
Added: pypy/trunk/pypy/module/cpyext/tupleobject.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/module/cpyext/tupleobject.py Sun Mar 21 01:18:50 2010
@@ -0,0 +1,13 @@
+from pypy.rpython.lltypesystem import rffi, lltype
+from pypy.module.cpyext.api import cpython_api, PyObject, Py_ssize_t
+from pypy.objspace.std.tupleobject import W_TupleObject
+
+
+ at cpython_api([Py_ssize_t], PyObject)
+def PyTuple_New(space, size):
+ return space.newtuple([space.w_None] * size)
+
+ at cpython_api([PyObject, Py_ssize_t, PyObject], rffi.INT)
+def PyTuple_SetItem(space, w_t, pos, w_obj):
+ assert isinstance(w_t, W_TupleObject)
+ w_t.wrappeditems[pos] = w_obj
More information about the Pypy-commit
mailing list