Commits

Amaury Forgeot d'Arc  committed 5cc488d

pyobj.h: split header and implementation.

  • Participants
  • Parent commits 3eea4e0
  • Branches remove-PYPY_NOT_MAIN_FILE

Comments (0)

Files changed (3)

File pypy/translator/c/genc.py

         srcdir / 'exception.c',
         srcdir / 'rtyper.c',
         srcdir / 'support.c',
+        srcdir / 'pyobj.c',
         srcdir / 'profiling.c',
         srcdir / 'debug_print.c',
         srcdir / 'debug_traceback.c',

File pypy/translator/c/src/pyobj.c

+#include <src/pyobj.h>
+
+/************************************************************/
+/***  C header subsection: untyped operations             ***/
+/***  as OP_XXX() macros calling the CPython API          ***/
+#ifdef PYPY_CPYTHON_EXTENSION
+
+#if (PY_VERSION_HEX < 0x02040000)
+
+unsigned long RPyLong_AsUnsignedLong(PyObject *v) 
+{
+	if (PyInt_Check(v)) {
+		long val = PyInt_AsLong(v);
+		if (val < 0) {
+			PyErr_SetNone(PyExc_OverflowError);
+			return (unsigned long)-1;
+		}
+		return val;
+        } else {
+		return PyLong_AsUnsignedLong(v);
+	}
+}
+
+#else
+#define RPyLong_AsUnsignedLong PyLong_AsUnsignedLong
+#endif
+
+
+unsigned long long RPyLong_AsUnsignedLongLong(PyObject *v)
+{
+	if (PyInt_Check(v))
+		return PyInt_AsLong(v);
+	else
+		return PyLong_AsUnsignedLongLong(v);
+}
+
+long long RPyLong_AsLongLong(PyObject *v)
+{
+	if (PyInt_Check(v))
+		return PyInt_AsLong(v);
+	else
+		return PyLong_AsLongLong(v);
+}
+
+#endif  /* PYPY_CPYTHON_EXTENSION */

File pypy/translator/c/src/pyobj.h

-
 /************************************************************/
- /***  C header subsection: untyped operations             ***/
-  /***  as OP_XXX() macros calling the CPython API          ***/
+/***  C header subsection: untyped operations             ***/
+/***  as OP_XXX() macros calling the CPython API          ***/
 #ifdef PYPY_CPYTHON_EXTENSION
 
 #define op_bool(r,what) { \
 unsigned long long RPyLong_AsUnsignedLongLong(PyObject *v);
 long long RPyLong_AsLongLong(PyObject *v);
 
-#ifdef PYPY_MAIN_IMPLEMENTATION_FILE
-
-#if (PY_VERSION_HEX < 0x02040000)
-
-unsigned long RPyLong_AsUnsignedLong(PyObject *v) 
-{
-	if (PyInt_Check(v)) {
-		long val = PyInt_AsLong(v);
-		if (val < 0) {
-			PyErr_SetNone(PyExc_OverflowError);
-			return (unsigned long)-1;
-		}
-		return val;
-        } else {
-		return PyLong_AsUnsignedLong(v);
-	}
-}
-
-#else
-#define RPyLong_AsUnsignedLong PyLong_AsUnsignedLong
-#endif
-
-
-unsigned long long RPyLong_AsUnsignedLongLong(PyObject *v)
-{
-	if (PyInt_Check(v))
-		return PyInt_AsLong(v);
-	else
-		return PyLong_AsUnsignedLongLong(v);
-}
-
-long long RPyLong_AsLongLong(PyObject *v)
-{
-	if (PyInt_Check(v))
-		return PyInt_AsLong(v);
-	else
-		return PyLong_AsLongLong(v);
-}
-
-#endif
-
 #endif  /* PYPY_CPYTHON_EXTENSION */