Extract common wrappers to Python compatibility header
This commit is contained in:
@ -27,25 +27,10 @@
|
||||
#include "neigh_list.h"
|
||||
#include "python.h"
|
||||
#include "error.h"
|
||||
#include "python_compat.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
// Wrap API changes between Python 2 and 3 using macros
|
||||
#if PY_MAJOR_VERSION == 2
|
||||
#define PY_INT_FROM_LONG(X) PyInt_FromLong(X)
|
||||
#define PY_INT_AS_LONG(X) PyInt_AsLong(X)
|
||||
#define PY_STRING_FROM_STRING(X) PyString_FromString(X)
|
||||
#define PY_VOID_POINTER(X) PyCObject_FromVoidPtr((void *) X, NULL)
|
||||
#define PY_STRING_AS_STRING(X) PyString_AsString(X)
|
||||
|
||||
#elif PY_MAJOR_VERSION == 3
|
||||
#define PY_INT_FROM_LONG(X) PyLong_FromLong(X)
|
||||
#define PY_INT_AS_LONG(X) PyLong_AsLong(X)
|
||||
#define PY_STRING_FROM_STRING(X) PyUnicode_FromString(X)
|
||||
#define PY_VOID_POINTER(X) PyCapsule_New((void *) X, NULL, NULL)
|
||||
#define PY_STRING_AS_STRING(X) PyUnicode_AsUTF8(X)
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairPython::PairPython(LAMMPS *lmp) : Pair(lmp) {
|
||||
|
||||
Reference in New Issue
Block a user