~ubuntu-branches/ubuntu/vivid/bzr/vivid

« back to all changes in this revision

Viewing changes to bzrlib/_simple_set_pyx_api.h

  • Committer: Jelmer Vernooij
  • Date: 2012-02-25 15:54:11 UTC
  • mfrom: (3930.3.71 unstable-2.5)
  • Revision ID: jelmer@samba.org-20120225155411-7nkz73y3xmshn2n8
Tags: 2.5.0-1ubuntu1
releasing version 2.5.0-1ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __PYX_HAVE_API__bzrlib___simple_set_pyx
 
2
#define __PYX_HAVE_API__bzrlib___simple_set_pyx
 
3
#include "Python.h"
 
4
#include "_simple_set_pyx.h"
 
5
 
 
6
static PyTypeObject *__pyx_ptype_6bzrlib_15_simple_set_pyx_SimpleSet;
 
7
#define SimpleSet_Type (*__pyx_ptype_6bzrlib_15_simple_set_pyx_SimpleSet)
 
8
 
 
9
static struct SimpleSetObject *(*SimpleSet_New)(void);
 
10
static PyObject *(*SimpleSet_Add)(PyObject *, PyObject *);
 
11
static int (*SimpleSet_Contains)(PyObject *, PyObject *);
 
12
static int (*SimpleSet_Discard)(PyObject *, PyObject *);
 
13
static PyObject *(*SimpleSet_Get)(struct SimpleSetObject *, PyObject *);
 
14
static Py_ssize_t (*SimpleSet_Size)(PyObject *);
 
15
static int (*SimpleSet_Next)(PyObject *, Py_ssize_t *, PyObject **);
 
16
static PyObject **(*_SimpleSet_Lookup)(PyObject *, PyObject *);
 
17
 
 
18
#ifndef __PYX_HAVE_API_FUNC_import_module
 
19
#define __PYX_HAVE_API_FUNC_import_module
 
20
 
 
21
#ifndef __PYX_HAVE_RT_ImportModule
 
22
#define __PYX_HAVE_RT_ImportModule
 
23
static PyObject *__Pyx_ImportModule(const char *name) {
 
24
    PyObject *py_name = 0;
 
25
    PyObject *py_module = 0;
 
26
 
 
27
    #if PY_MAJOR_VERSION < 3
 
28
    py_name = PyString_FromString(name);
 
29
    #else
 
30
    py_name = PyUnicode_FromString(name);
 
31
    #endif
 
32
    if (!py_name)
 
33
        goto bad;
 
34
    py_module = PyImport_Import(py_name);
 
35
    Py_DECREF(py_name);
 
36
    return py_module;
 
37
bad:
 
38
    Py_XDECREF(py_name);
 
39
    return 0;
 
40
}
 
41
#endif
 
42
 
 
43
#endif
 
44
 
 
45
 
 
46
#ifndef __PYX_HAVE_RT_ImportFunction
 
47
#define __PYX_HAVE_RT_ImportFunction
 
48
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
 
49
    PyObject *d = 0;
 
50
    PyObject *cobj = 0;
 
51
    union {
 
52
        void (*fp)(void);
 
53
        void *p;
 
54
    } tmp;
 
55
 
 
56
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
 
57
    if (!d)
 
58
        goto bad;
 
59
    cobj = PyDict_GetItemString(d, funcname);
 
60
    if (!cobj) {
 
61
        PyErr_Format(PyExc_ImportError,
 
62
            "%s does not export expected C function %s",
 
63
                PyModule_GetName(module), funcname);
 
64
        goto bad;
 
65
    }
 
66
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
 
67
    if (!PyCapsule_IsValid(cobj, sig)) {
 
68
        PyErr_Format(PyExc_TypeError,
 
69
            "C function %s.%s has wrong signature (expected %s, got %s)",
 
70
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
 
71
        goto bad;
 
72
    }
 
73
    tmp.p = PyCapsule_GetPointer(cobj, sig);
 
74
#else
 
75
    {const char *desc, *s1, *s2;
 
76
    desc = (const char *)PyCObject_GetDesc(cobj);
 
77
    if (!desc)
 
78
        goto bad;
 
79
    s1 = desc; s2 = sig;
 
80
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
 
81
    if (*s1 != *s2) {
 
82
        PyErr_Format(PyExc_TypeError,
 
83
            "C function %s.%s has wrong signature (expected %s, got %s)",
 
84
             PyModule_GetName(module), funcname, sig, desc);
 
85
        goto bad;
 
86
    }
 
87
    tmp.p = PyCObject_AsVoidPtr(cobj);}
 
88
#endif
 
89
    *f = tmp.fp;
 
90
    if (!(*f))
 
91
        goto bad;
 
92
    Py_DECREF(d);
 
93
    return 0;
 
94
bad:
 
95
    Py_XDECREF(d);
 
96
    return -1;
 
97
}
 
98
#endif
 
99
 
 
100
 
 
101
#ifndef __PYX_HAVE_RT_ImportType
 
102
#define __PYX_HAVE_RT_ImportType
 
103
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
 
104
    long size, int strict)
 
105
{
 
106
    PyObject *py_module = 0;
 
107
    PyObject *result = 0;
 
108
    PyObject *py_name = 0;
 
109
    char warning[200];
 
110
 
 
111
    py_module = __Pyx_ImportModule(module_name);
 
112
    if (!py_module)
 
113
        goto bad;
 
114
    #if PY_MAJOR_VERSION < 3
 
115
    py_name = PyString_FromString(class_name);
 
116
    #else
 
117
    py_name = PyUnicode_FromString(class_name);
 
118
    #endif
 
119
    if (!py_name)
 
120
        goto bad;
 
121
    result = PyObject_GetAttr(py_module, py_name);
 
122
    Py_DECREF(py_name);
 
123
    py_name = 0;
 
124
    Py_DECREF(py_module);
 
125
    py_module = 0;
 
126
    if (!result)
 
127
        goto bad;
 
128
    if (!PyType_Check(result)) {
 
129
        PyErr_Format(PyExc_TypeError,
 
130
            "%s.%s is not a type object",
 
131
            module_name, class_name);
 
132
        goto bad;
 
133
    }
 
134
    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
 
135
        PyOS_snprintf(warning, sizeof(warning),
 
136
            "%s.%s size changed, may indicate binary incompatibility",
 
137
            module_name, class_name);
 
138
        #if PY_VERSION_HEX < 0x02050000
 
139
        PyErr_Warn(NULL, warning);
 
140
        #else
 
141
        PyErr_WarnEx(NULL, warning, 0);
 
142
        #endif
 
143
    }
 
144
    else if (((PyTypeObject *)result)->tp_basicsize != size) {
 
145
        PyErr_Format(PyExc_ValueError,
 
146
            "%s.%s has the wrong size, try recompiling",
 
147
            module_name, class_name);
 
148
        goto bad;
 
149
    }
 
150
    return (PyTypeObject *)result;
 
151
bad:
 
152
    Py_XDECREF(py_module);
 
153
    Py_XDECREF(result);
 
154
    return 0;
 
155
}
 
156
#endif
 
157
 
 
158
static int import_bzrlib___simple_set_pyx(void) {
 
159
  PyObject *module = 0;
 
160
  module = __Pyx_ImportModule("bzrlib._simple_set_pyx");
 
161
  if (!module) goto bad;
 
162
  if (__Pyx_ImportFunction(module, "SimpleSet_New", (void (**)(void))&SimpleSet_New, "struct SimpleSetObject *(void)") < 0) goto bad;
 
163
  if (__Pyx_ImportFunction(module, "SimpleSet_Add", (void (**)(void))&SimpleSet_Add, "PyObject *(PyObject *, PyObject *)") < 0) goto bad;
 
164
  if (__Pyx_ImportFunction(module, "SimpleSet_Contains", (void (**)(void))&SimpleSet_Contains, "int (PyObject *, PyObject *)") < 0) goto bad;
 
165
  if (__Pyx_ImportFunction(module, "SimpleSet_Discard", (void (**)(void))&SimpleSet_Discard, "int (PyObject *, PyObject *)") < 0) goto bad;
 
166
  if (__Pyx_ImportFunction(module, "SimpleSet_Get", (void (**)(void))&SimpleSet_Get, "PyObject *(struct SimpleSetObject *, PyObject *)") < 0) goto bad;
 
167
  if (__Pyx_ImportFunction(module, "SimpleSet_Size", (void (**)(void))&SimpleSet_Size, "Py_ssize_t (PyObject *)") < 0) goto bad;
 
168
  if (__Pyx_ImportFunction(module, "SimpleSet_Next", (void (**)(void))&SimpleSet_Next, "int (PyObject *, Py_ssize_t *, PyObject **)") < 0) goto bad;
 
169
  if (__Pyx_ImportFunction(module, "_SimpleSet_Lookup", (void (**)(void))&_SimpleSet_Lookup, "PyObject **(PyObject *, PyObject *)") < 0) goto bad;
 
170
  Py_DECREF(module); module = 0;
 
171
  __pyx_ptype_6bzrlib_15_simple_set_pyx_SimpleSet = __Pyx_ImportType("bzrlib._simple_set_pyx", "SimpleSet", sizeof(struct SimpleSetObject), 1); if (!__pyx_ptype_6bzrlib_15_simple_set_pyx_SimpleSet) goto bad;
 
172
  return 0;
 
173
  bad:
 
174
  Py_XDECREF(module);
 
175
  return -1;
 
176
}
 
177
 
 
178
#endif