aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/pybind/init.h
blob: 58874574ed6b9bf9c06c6c585de5d2d2e060989a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once

#define PY_SSIZE_T_CLEAN
#include <Python.h>

#include "ptr.h"

namespace NPyBind {
#if PY_MAJOR_VERSION >= 3

#define PYBIND_MODINIT(name) PyMODINIT_FUNC PyInit_##name()

    inline PyObject* ModInitReturn(TPyObjectPtr&& modptr) {
        return modptr.Release();
    }

#else

#define PYBIND_MODINIT(name) PyMODINIT_FUNC init##name()

    inline void ModInitReturn(TPyObjectPtr&&) {
    }

#endif
}