/[thuban]/branches/WIP-pyshapelib-bramz/libraries/pyshapelib/pyshapelib_common.h
ViewVC logotype

Contents of /branches/WIP-pyshapelib-bramz/libraries/pyshapelib/pyshapelib_common.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2752 - (show annotations)
Tue Apr 10 23:45:00 2007 UTC (17 years, 10 months ago) by bramz
File MIME type: text/plain
File size: 3463 byte(s)
attempt to add support for Unicode and Language Driver ID (LDID) support in dbflib
1 /* Copyright (c) 2007 by Intevation GmbH
2 * Authors:
3 * Bram de Greve <[email protected]>
4 *
5 * This program is free software under the GPL (>=v2)
6 * Read the file COPYING coming with Thuban for details.
7 */
8
9 #ifndef PYSHAPELIB_H
10 #define PYSHAPELIB_H
11
12 #include <Python.h>
13 #include <structmember.h>
14 #include "shapefil.h"
15 #include "pyshapelib_api.h"
16
17 /* WIDE-CHARACTER FILENAME SUPPORT FOR WINDOWS
18 *
19 * pyshapelib can support full Unicode strings as filename on the Windows platform
20 * trough the wide-character version of the Win API. At this moment, however, this
21 * needs unofficial modifications to the shapelib library to be able to use this API.
22 *
23 * A ticket has been made in the maptools Bugzilla with patches for the 1.2.10 release
24 * of shapelib: http://bugzilla.maptools.org/show_bug.cgi?id=1692
25 *
26 * The version of shapelib that is contained in the thuban source tree already contains
27 * these modifications.
28 */
29 #if defined(SHPAPI_HAS_WIDE) && defined(Py_WIN_WIDE_FILENAMES)
30 /* Need GetVersion to see if on NT so safe to use _wfopen */
31 # define WIN32_LEAN_AND_MEAN
32 # include <windows.h>
33 #endif
34
35 /* ---------------------------------------------------------------------------------------------- */
36
37 /* helper to export constants (macros) to Python.
38 * The constant in Python will have the same name as in C
39 */
40 #define PYSHAPELIB_ADD_CONSTANT(constant) PyModule_AddIntConstant(module, #constant, constant)
41
42 /* helper to define the type object.
43 *
44 * This assumes quite a few things about different things being available and their name.
45 * For example, if prefix = foo, then there should be a deallocation function called foo_dealloc.
46 * See the macro itself for other examples.
47 */
48 #define PYSHAPELIB_DEFINE_TYPE(object, prefix, name, doc) \
49 { \
50 PyObject_HEAD_INIT(NULL) \
51 0, /*ob_size*/ \
52 name, /*tp_name*/ \
53 sizeof(object), /*tp_basicsize*/ \
54 0, /*tp_itemsize*/ \
55 (destructor) prefix ## _dealloc, /*tp_dealloc*/ \
56 0, /*tp_print*/ \
57 0, /*tp_getattr*/ \
58 0, /*tp_setattr*/ \
59 0, /*tp_compare*/ \
60 (reprfunc) prefix ## _repr, /*tp_repr*/ \
61 0, /*tp_as_number*/ \
62 0, /*tp_as_sequence*/ \
63 0, /*tp_as_mapping*/ \
64 0, /*tp_hash */ \
65 0, /*tp_call*/ \
66 0, /*tp_str*/ \
67 0, /*tp_getattro*/ \
68 0, /*tp_setattro*/ \
69 0, /*tp_as_buffer*/ \
70 Py_TPFLAGS_DEFAULT, /*tp_flags*/ \
71 doc, /* tp_doc */ \
72 0, /* tp_traverse */ \
73 0, /* tp_clear */ \
74 0, /* tp_richcompare */ \
75 0, /* tp_weaklistoffset */ \
76 0, /* tp_iter */ \
77 0, /* tp_iternext */ \
78 prefix ## _methods, /* tp_methods */ \
79 0, /* tp_members */ \
80 prefix ## _getsetters, /* tp_getset */ \
81 0, /* tp_base */ \
82 0, /* tp_dict */ \
83 0, /* tp_descr_get */ \
84 0, /* tp_descr_set */ \
85 0, /* tp_dictoffset */ \
86 (initproc) prefix ## _init, /* tp_init */ \
87 0, /* tp_alloc */ \
88 prefix ## _new, /* tp_new */ \
89 } \
90 /**/
91
92 /* helper to add type to module.
93 * Does a bit of the tedious bookkeeping for us
94 */
95 #define PYSHAPELIB_ADD_TYPE(type, name) \
96 type.ob_type = &PyType_Type; \
97 if (PyType_Ready(&type) >= 0) \
98 { \
99 Py_INCREF(&type); \
100 PyModule_AddObject(module, name, (PyObject*)&type); \
101 }
102
103 #define PYSHAPELIB_NO_DATA_LIMIT 1e-38
104 #define PYSHAPELIB_NO_DATA 0
105
106 #endif

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26