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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2751 - (hide annotations)
Wed Mar 28 23:30:15 2007 UTC (17 years, 11 months ago) by bramz
File MIME type: text/plain
File size: 2633 byte(s)
Added support for Win32 wide character file API.  Unicode filenames are now fully supported on the windows platform: for example exotic filenames like the greek letter pi (u"\u03c0").  However, this needed unofficial modifications in the C++ shapelib library.
1 bramz 2735 #ifndef PYSHAPELIB_H
2     #define PYSHAPELIB_H
3    
4     #include <Python.h>
5     #include <structmember.h>
6 bramz 2742 #include "shapefil.h"
7     #include "pyshapelib_api.h"
8 bramz 2735
9 bramz 2751 #if defined(SHPAPI_HAS_WIDE) && defined(Py_WIN_WIDE_FILENAMES)
10     /* Need GetVersion to see if on NT so safe to use _wfopen */
11     # define WIN32_LEAN_AND_MEAN
12     # include <windows.h>
13     #endif
14    
15 bramz 2741 /* helper to export constants (macros) to Python.
16     * The constant in Python will have the same name as in C
17     */
18 bramz 2735 #define PYSHAPELIB_ADD_CONSTANT(constant) PyModule_AddIntConstant(module, #constant, constant)
19    
20 bramz 2741 /* helper to define the type object.
21     *
22     * This assumes quite a few things about different things being available and their name.
23 bramz 2742 * For example, if prefix = foo, then there should be a deallocation function called foo_dealloc.
24 bramz 2741 * See the macro itself for other examples.
25     */
26 bramz 2742 #define PYSHAPELIB_DEFINE_TYPE(object, prefix, name, doc) \
27 bramz 2735 { \
28     PyObject_HEAD_INIT(NULL) \
29 bramz 2742 0, /*ob_size*/ \
30     name, /*tp_name*/ \
31     sizeof(object), /*tp_basicsize*/ \
32     0, /*tp_itemsize*/ \
33     (destructor) prefix ## _dealloc, /*tp_dealloc*/ \
34     0, /*tp_print*/ \
35     0, /*tp_getattr*/ \
36     0, /*tp_setattr*/ \
37     0, /*tp_compare*/ \
38     (reprfunc) prefix ## _repr, /*tp_repr*/ \
39     0, /*tp_as_number*/ \
40     0, /*tp_as_sequence*/ \
41     0, /*tp_as_mapping*/ \
42     0, /*tp_hash */ \
43     0, /*tp_call*/ \
44     0, /*tp_str*/ \
45     0, /*tp_getattro*/ \
46     0, /*tp_setattro*/ \
47     0, /*tp_as_buffer*/ \
48     Py_TPFLAGS_DEFAULT, /*tp_flags*/ \
49     doc, /* tp_doc */ \
50     0, /* tp_traverse */ \
51     0, /* tp_clear */ \
52     0, /* tp_richcompare */ \
53     0, /* tp_weaklistoffset */ \
54     0, /* tp_iter */ \
55     0, /* tp_iternext */ \
56     prefix ## _methods, /* tp_methods */ \
57     0, /* tp_members */ \
58     prefix ## _getsetters, /* tp_getset */ \
59     0, /* tp_base */ \
60     0, /* tp_dict */ \
61     0, /* tp_descr_get */ \
62     0, /* tp_descr_set */ \
63     0, /* tp_dictoffset */ \
64     (initproc) prefix ## _init, /* tp_init */ \
65     0, /* tp_alloc */ \
66     prefix ## _new, /* tp_new */ \
67 bramz 2735 } \
68     /**/
69    
70 bramz 2741 /* helper to add type to module.
71     * Does a bit of the tedious bookkeeping for us
72     */
73 bramz 2735 #define PYSHAPELIB_ADD_TYPE(type, name) \
74     type.ob_type = &PyType_Type; \
75     if (PyType_Ready(&type) >= 0) \
76     { \
77     Py_INCREF(&type); \
78     PyModule_AddObject(module, name, (PyObject*)&type); \
79     }
80    
81 bramz 2745 #define PYSHAPELIB_NO_DATA_LIMIT 1e-38
82     #define PYSHAPELIB_NO_DATA 0
83    
84 bramz 2735 #endif

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26