/[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 2745 - (show annotations)
Thu Mar 15 22:27:02 2007 UTC (17 years, 11 months ago) by bramz
File MIME type: text/plain
File size: 2449 byte(s)
Added FTLogical support to dbflib.  Accept None as no-data for M values.  Added name and mode keywords to mimic Python's file behaviour where appropriate.  Added unpack_vertex() to lift some load of shpobject_init().
1 #ifndef PYSHAPELIB_H
2 #define PYSHAPELIB_H
3
4 #include <Python.h>
5 #include <structmember.h>
6 #include "shapefil.h"
7 #include "pyshapelib_api.h"
8
9 /* helper to export constants (macros) to Python.
10 * The constant in Python will have the same name as in C
11 */
12 #define PYSHAPELIB_ADD_CONSTANT(constant) PyModule_AddIntConstant(module, #constant, constant)
13
14 /* helper to define the type object.
15 *
16 * This assumes quite a few things about different things being available and their name.
17 * For example, if prefix = foo, then there should be a deallocation function called foo_dealloc.
18 * See the macro itself for other examples.
19 */
20 #define PYSHAPELIB_DEFINE_TYPE(object, prefix, name, doc) \
21 { \
22 PyObject_HEAD_INIT(NULL) \
23 0, /*ob_size*/ \
24 name, /*tp_name*/ \
25 sizeof(object), /*tp_basicsize*/ \
26 0, /*tp_itemsize*/ \
27 (destructor) prefix ## _dealloc, /*tp_dealloc*/ \
28 0, /*tp_print*/ \
29 0, /*tp_getattr*/ \
30 0, /*tp_setattr*/ \
31 0, /*tp_compare*/ \
32 (reprfunc) prefix ## _repr, /*tp_repr*/ \
33 0, /*tp_as_number*/ \
34 0, /*tp_as_sequence*/ \
35 0, /*tp_as_mapping*/ \
36 0, /*tp_hash */ \
37 0, /*tp_call*/ \
38 0, /*tp_str*/ \
39 0, /*tp_getattro*/ \
40 0, /*tp_setattro*/ \
41 0, /*tp_as_buffer*/ \
42 Py_TPFLAGS_DEFAULT, /*tp_flags*/ \
43 doc, /* tp_doc */ \
44 0, /* tp_traverse */ \
45 0, /* tp_clear */ \
46 0, /* tp_richcompare */ \
47 0, /* tp_weaklistoffset */ \
48 0, /* tp_iter */ \
49 0, /* tp_iternext */ \
50 prefix ## _methods, /* tp_methods */ \
51 0, /* tp_members */ \
52 prefix ## _getsetters, /* tp_getset */ \
53 0, /* tp_base */ \
54 0, /* tp_dict */ \
55 0, /* tp_descr_get */ \
56 0, /* tp_descr_set */ \
57 0, /* tp_dictoffset */ \
58 (initproc) prefix ## _init, /* tp_init */ \
59 0, /* tp_alloc */ \
60 prefix ## _new, /* tp_new */ \
61 } \
62 /**/
63
64 /* helper to add type to module.
65 * Does a bit of the tedious bookkeeping for us
66 */
67 #define PYSHAPELIB_ADD_TYPE(type, name) \
68 type.ob_type = &PyType_Type; \
69 if (PyType_Ready(&type) >= 0) \
70 { \
71 Py_INCREF(&type); \
72 PyModule_AddObject(module, name, (PyObject*)&type); \
73 }
74
75 #define PYSHAPELIB_NO_DATA_LIMIT 1e-38
76 #define PYSHAPELIB_NO_DATA 0
77
78 #endif

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26