Debian Codegraph @

src/main/c/jpy_compat.h

raw symbols SCIP
1 /*
2 * Copyright 2015 Brockmann Consult GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef JPY_COMPAT_H
18 #define JPY_COMPAT_H
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include <Python.h>
25 #include "frameobject.h"
26
27 #define JPY_VERSION_ERROR "jpy requires Python 3.9+"
28
29 #if PY_MAJOR_VERSION < 3 || PY_MINOR_VERSION < 9
30 #error JPY_VERSION_ERROR
31 #endif
32
33 #define JPy_IS_CLONG(pyArg) PyLong_Check(pyArg)
34 #define JPy_AS_CLONG(pyArg) PyLong_AsLong(pyArg)
35 #define JPy_AS_CLONGLONG(pyArg) PyLong_AsLongLong(pyArg)
36 #define JPy_FROM_CLONG(cl) PyLong_FromLong(cl)
37
38 #define JPy_IS_STR(pyArg) PyUnicode_Check(pyArg)
39 #define JPy_FROM_CSTR(cstr) PyUnicode_FromString(cstr)
40 #define JPy_FROM_FORMAT PyUnicode_FromFormat
41
42 #define JPy_AS_UTF8(unicode) PyUnicode_AsUTF8(unicode)
43 #define JPy_AS_WIDE_CHAR_STR(unicode, size) PyUnicode_AsWideCharString(unicode, size)
44 #define JPy_FROM_WIDE_CHAR_STR(wc, size) PyUnicode_FromKindAndData(PyUnicode_2BYTE_KIND, wc, size)
45
46 #ifdef __cplusplus
47 } /* extern "C" */
48 #endif
49 #endif /* !JPY_COMPAT_H */