File: libzim_api.h

package info (click to toggle)
python-libzim 2.1.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,660 kB
  • sloc: python: 1,193; cpp: 394; makefile: 5
file content (117 lines) | stat: -rw-r--r-- 6,350 bytes parent folder | download
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* Generated by Cython 0.29.32 */

#ifndef __PYX_HAVE_API__libzim
#define __PYX_HAVE_API__libzim
#ifdef __MINGW64__
#define MS_WIN64
#endif
#include "Python.h"
#include "libzim.h"

static bool (*__pyx_api_f_6libzim_obj_has_attribute)(PyObject *, std::string) = 0;
#define obj_has_attribute __pyx_api_f_6libzim_obj_has_attribute
static std::string (*__pyx_api_f_6libzim_string_cy_call_fct)(PyObject *, std::string, std::string *) = 0;
#define string_cy_call_fct __pyx_api_f_6libzim_string_cy_call_fct
static wrapper::Blob (*__pyx_api_f_6libzim_blob_cy_call_fct)(PyObject *, std::string, std::string *) = 0;
#define blob_cy_call_fct __pyx_api_f_6libzim_blob_cy_call_fct
static zim::writer::ContentProvider *(*__pyx_api_f_6libzim_contentprovider_cy_call_fct)(PyObject *, std::string, std::string *) = 0;
#define contentprovider_cy_call_fct __pyx_api_f_6libzim_contentprovider_cy_call_fct
static zim::writer::IndexData *(*__pyx_api_f_6libzim_indexdata_cy_call_fct)(PyObject *, std::string, std::string *) = 0;
#define indexdata_cy_call_fct __pyx_api_f_6libzim_indexdata_cy_call_fct
static bool (*__pyx_api_f_6libzim_bool_cy_call_fct)(PyObject *, std::string, std::string *) = 0;
#define bool_cy_call_fct __pyx_api_f_6libzim_bool_cy_call_fct
static uint64_t (*__pyx_api_f_6libzim_uint64_cy_call_fct)(PyObject *, std::string, std::string *) = 0;
#define uint64_cy_call_fct __pyx_api_f_6libzim_uint64_cy_call_fct
static uint32_t (*__pyx_api_f_6libzim_uint32_cy_call_fct)(PyObject *, std::string, std::string *) = 0;
#define uint32_cy_call_fct __pyx_api_f_6libzim_uint32_cy_call_fct
static zim::writer::IndexData::GeoPosition (*__pyx_api_f_6libzim_geoposition_cy_call_fct)(PyObject *, std::string, std::string *) = 0;
#define geoposition_cy_call_fct __pyx_api_f_6libzim_geoposition_cy_call_fct
static std::map<zim::writer::HintKeys,uint64_t>  (*__pyx_api_f_6libzim_convertToCppHints)(PyObject *) = 0;
#define convertToCppHints __pyx_api_f_6libzim_convertToCppHints
static std::map<zim::writer::HintKeys,uint64_t>  (*__pyx_api_f_6libzim_hints_cy_call_fct)(PyObject *, std::string, std::string *) = 0;
#define hints_cy_call_fct __pyx_api_f_6libzim_hints_cy_call_fct
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif


static int import_libzim(void) {
  PyObject *module = 0;
  module = PyImport_ImportModule("libzim");
  if (!module) goto bad;
  if (__Pyx_ImportFunction(module, "obj_has_attribute", (void (**)(void))&__pyx_api_f_6libzim_obj_has_attribute, "bool (PyObject *, std::string)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "string_cy_call_fct", (void (**)(void))&__pyx_api_f_6libzim_string_cy_call_fct, "std::string (PyObject *, std::string, std::string *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "blob_cy_call_fct", (void (**)(void))&__pyx_api_f_6libzim_blob_cy_call_fct, "wrapper::Blob (PyObject *, std::string, std::string *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "contentprovider_cy_call_fct", (void (**)(void))&__pyx_api_f_6libzim_contentprovider_cy_call_fct, "zim::writer::ContentProvider *(PyObject *, std::string, std::string *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "indexdata_cy_call_fct", (void (**)(void))&__pyx_api_f_6libzim_indexdata_cy_call_fct, "zim::writer::IndexData *(PyObject *, std::string, std::string *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "bool_cy_call_fct", (void (**)(void))&__pyx_api_f_6libzim_bool_cy_call_fct, "bool (PyObject *, std::string, std::string *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "uint64_cy_call_fct", (void (**)(void))&__pyx_api_f_6libzim_uint64_cy_call_fct, "uint64_t (PyObject *, std::string, std::string *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "uint32_cy_call_fct", (void (**)(void))&__pyx_api_f_6libzim_uint32_cy_call_fct, "uint32_t (PyObject *, std::string, std::string *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "geoposition_cy_call_fct", (void (**)(void))&__pyx_api_f_6libzim_geoposition_cy_call_fct, "zim::writer::IndexData::GeoPosition (PyObject *, std::string, std::string *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "convertToCppHints", (void (**)(void))&__pyx_api_f_6libzim_convertToCppHints, "std::map<zim::writer::HintKeys,uint64_t>  (PyObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "hints_cy_call_fct", (void (**)(void))&__pyx_api_f_6libzim_hints_cy_call_fct, "std::map<zim::writer::HintKeys,uint64_t>  (PyObject *, std::string, std::string *)") < 0) goto bad;
  Py_DECREF(module); module = 0;
  return 0;
  bad:
  Py_XDECREF(module);
  return -1;
}

#endif /* !__PYX_HAVE_API__libzim */