File: pydia-geometry.c

package info (click to toggle)
dia 0.97.3%2Bgit20160930-9
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 54,372 kB
  • sloc: ansic: 155,065; xml: 16,326; python: 6,641; cpp: 4,935; makefile: 3,833; sh: 540; perl: 137; sed: 19
file content (682 lines) | stat: -rw-r--r-- 17,185 bytes parent folder | download | duplicates (3)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
/* Python plug-in for dia
 * Copyright (C) 1999  James Henstridge
 * Copyright (C) 2000  Hans Breuer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <config.h>

#include "pydia-object.h"
#include "pydia-geometry.h"

#include <structmember.h> /* PyMemberDef */

/* Implements wrappers for Point, Rectangle, IntRectangle, BezPoint */

/*
 * New
 */
PyObject* PyDiaPoint_New (Point* pt)
{
  PyDiaPoint *self;
  
  self = PyObject_NEW(PyDiaPoint, &PyDiaPoint_Type);
  if (!self) return NULL;
  
  self->pt = *pt;

  return (PyObject *)self;
}

PyObject* 
PyDiaPointTuple_New (Point* pts, int num)
{
  PyObject* ret;
  int i;

  ret = PyTuple_New (num);
  if (ret) {
    for (i = 0; i < num; i++)
      PyTuple_SetItem(ret, i, PyDiaPoint_New(&(pts[i])));
  }

  return ret;
}

/* one of the parameters needs to be NULL, the other is created */
PyObject* 
PyDiaRectangle_New (Rectangle* r, IntRectangle* ri)
{
  PyDiaRectangle *self;

  self = PyObject_NEW(PyDiaRectangle, &PyDiaRectangle_Type);
  if (!self) return NULL;

  self->is_int = (ri != NULL);
  if (self->is_int)
    self->r.ri = *ri;
  else
    self->r.rf = *r;

  return (PyObject *)self;
}

PyObject* PyDiaRectangle_New_FromPoints (Point* ul, Point* lr)
{
  PyDiaRectangle *self;

  self = PyObject_NEW(PyDiaRectangle, &PyDiaRectangle_Type);
  if (!self) return NULL;

  self->is_int = FALSE;
  self->r.rf.left = ul->x;
  self->r.rf.top = ul->y;
  self->r.rf.right = lr->x;
  self->r.rf.bottom = lr->y;

  return (PyObject *)self;
}


PyObject* PyDiaBezPoint_New (BezPoint* bpn)
{
  PyDiaBezPoint *self;
  
  self = PyObject_NEW(PyDiaBezPoint, &PyDiaBezPoint_Type);
  if (!self) return NULL;
  
  self->bpn = *bpn;

  return (PyObject *)self;
}

PyObject* 
PyDiaBezPointTuple_New (BezPoint* pts, int num)
{
  PyObject* ret;
  int i;

  ret = PyTuple_New (num);
  if (ret) {
    for (i = 0; i < num; i++)
      PyTuple_SetItem(ret, i, PyDiaBezPoint_New(&(pts[i])));
  }

  return ret;
}

PyObject* PyDiaArrow_New (Arrow* arrow)
{
  PyDiaArrow *self;
  
  self = PyObject_NEW(PyDiaArrow, &PyDiaArrow_Type);
  if (!self) return NULL;
  
  self->arrow = *arrow;

  return (PyObject *)self;
}

PyObject*
PyDiaMatrix_New (DiaMatrix *matrix)
{
  PyDiaMatrix *self;

  self = PyObject_NEW(PyDiaMatrix, &PyDiaMatrix_Type);
  if (!self) return NULL;
  
  if (matrix)
    self->matrix = *matrix;
  else {
    /* identity matrix */
    self->matrix.xx = self->matrix.yy = 1.0;
    self->matrix.xy = self->matrix.yx = self->matrix.x0 = self->matrix.y0 = 0.0;
  } 

  return (PyObject *)self;
}
/*
 * Dealloc
 */
static void
PyDiaGeometry_Dealloc(void *self)
{
     PyObject_DEL(self);
}

/*
 * Compare ?
 */
static int
PyDiaPoint_Compare(PyDiaPoint *self,
			     PyDiaPoint *other)
{
#if 1
  return memcmp (&self->pt, &other->pt, sizeof(Point));
#else /* ? */
  if (self->pt.x == other->pt.x && self->pt.x == other->pt.x) return 0;
#define SQR(pt) (pt.x*pt.y)
  if (SQR(self->pt) > SQR(other->pt)) return -1;
#undef  SQR 
  return 1;
#endif
}

static int
PyDiaRectangle_Compare(PyDiaRectangle *self,
			     PyDiaRectangle *other)
{
  /* this is not correct */
  return memcmp (&self->r, &other->r, sizeof(Rectangle));
}

static int
PyDiaBezPoint_Compare(PyDiaBezPoint *self,
			     PyDiaBezPoint *other)
{
  return memcmp (&self->bpn, &other->bpn, sizeof(BezPoint));
}

static int
PyDiaArrow_Compare(PyDiaArrow *self,
			 PyDiaArrow *other)
{
  return memcmp (&self->arrow, &other->arrow, sizeof(Arrow));
}

static int
PyDiaMatrix_Compare(PyDiaMatrix *self,
		    PyDiaMatrix *other)
{
  return memcmp (&self->matrix, &other->matrix, sizeof(DiaMatrix));
}

/*
 * Hash
 */
static long
PyDiaGeometry_Hash(PyObject *self)
{
    return (long)self;
}

static PyObject *
PyDiaRectangle_GetAttr(PyDiaRectangle *self, gchar *attr)
{
#define I_OR_F(v) \
  (self->is_int ? \
   PyInt_FromLong(self->r.ri. v) : PyFloat_FromDouble(self->r.rf. v))

  if (!strcmp(attr, "__members__"))
    return Py_BuildValue("[ssss]", "top", "left", "right", "bottom" );
  else if (!strcmp(attr, "top"))
    return I_OR_F(top);
  else if (!strcmp(attr, "left"))
    return I_OR_F(left);
  else if (!strcmp(attr, "right"))
    return I_OR_F(right);
  else if (!strcmp(attr, "bottom"))
    return I_OR_F(bottom);

  PyErr_SetString(PyExc_AttributeError, attr);
  return NULL;

#undef I_O_F
}

static PyObject *
PyDiaBezPoint_GetAttr(PyDiaBezPoint *self, gchar *attr)
{
  if (!strcmp(attr, "__members__"))
    return Py_BuildValue("[ssss]", "type", "p1", "p2", "p3");
  else if (!strcmp(attr, "type"))
    return PyInt_FromLong(self->bpn.type);
  else if (!strcmp(attr, "p1"))
    return PyDiaPoint_New(&(self->bpn.p1));
  else if (!strcmp(attr, "p2"))
    return PyDiaPoint_New(&(self->bpn.p2));
  else if (!strcmp(attr, "p3"))
    return PyDiaPoint_New(&(self->bpn.p3));

  PyErr_SetString(PyExc_AttributeError, attr);
  return NULL;
}

/*
 * SetAttr
 */

/* XXX */

/*
 * Repr / _Str
 */
static PyObject *
PyDiaPoint_Str(PyDiaPoint *self)
{
    PyObject* py_s;
#ifndef _DEBUG /* gives crashes with nan */
    gchar* s = g_strdup_printf ("(%f,%f)",
                                (float)(self->pt.x), (float)(self->pt.y));
#else
    gchar* s = g_strdup_printf ("(%e,%e)",
                                (float)(self->pt.x), (float)(self->pt.y));
#endif
    py_s = PyString_FromString(s);
    g_free(s);
    return py_s;
}

static PyObject *
PyDiaRectangle_Str(PyDiaRectangle *self)
{
    PyObject* py_s;
    gchar* s;
    if (self->is_int)
      s = g_strdup_printf ("((%d,%d),(%d,%d))",
                           (self->r.ri.left), (self->r.ri.top),
                           (self->r.ri.right), (self->r.ri.bottom));
    else
#ifndef _DEBUG /* gives crashes with nan */
      s = g_strdup_printf ("((%f,%f),(%f,%f))",
                           (float)(self->r.rf.left), (float)(self->r.rf.top),
                           (float)(self->r.rf.right), (float)(self->r.rf.bottom));
#else
      s = g_strdup_printf ("((%e,%e),(%e,%e))",
                           (float)(self->r.rf.left), (float)(self->r.rf.top),
                           (float)(self->r.rf.right), (float)(self->r.rf.bottom));
#endif
    py_s = PyString_FromString(s);
    g_free(s);
    return py_s;
}

static PyObject *
PyDiaBezPoint_Str(PyDiaBezPoint *self)
{
    PyObject* py_s;
#if 0 /* FIXME: this is causing bad crashes with unintialized points. 
       * Probably a glib and a Dia problem ... */
    gchar* s = g_strdup_printf ("((%f,%f),(%f,%f),(%f,%f),%s)",
                                (float)(self->bpn.p1.x), (float)(self->bpn.p1.y),
                                (float)(self->bpn.p2.x), (float)(self->bpn.p2.y),
                                (float)(self->bpn.p3.x), (float)(self->bpn.p3.y),
                                (self->bpn.type == BEZ_MOVE_TO ? "MOVE_TO" :
                                  (self->bpn.type == BEZ_LINE_TO ? "LINE_TO" : "CURVE_TO")));
#else
    gchar* s = g_strdup_printf ("%s",
                                (self->bpn.type == BEZ_MOVE_TO ? "MOVE_TO" :
                                  (self->bpn.type == BEZ_LINE_TO ? "LINE_TO" : "CURVE_TO")));
#endif
    py_s = PyString_FromString(s);
    g_free(s);
    return py_s;
}


static PyObject *
PyDiaArrow_Str(PyDiaArrow *self)
{
    PyObject* py_s;
    gchar* s = g_strdup_printf ("(%f,%f, %d)",
                                (float)(self->arrow.width), 
                                (float)(self->arrow.length),
                                (int)(self->arrow.type));
    py_s = PyString_FromString(s);
    g_free(s);
    return py_s;
}

static PyObject *
PyDiaMatrix_Str(PyDiaMatrix *self)
{
    PyObject* py_s;
    gchar* s = g_strdup_printf ("(%f, %f, %f, %f, %f, %f)",
                                (float)(self->matrix.xx),
                                (float)(self->matrix.yx),
                                (float)(self->matrix.xy),
                                (float)(self->matrix.yy),
                                (float)(self->matrix.x0),
                                (float)(self->matrix.y0));
    py_s = PyString_FromString(s);
    g_free(s);
    return py_s;
}

/* 
 * sequence interface (query only) 
 */
/* Point */
static gssize
point_length(PyObject *self)
{
  return 2;
}
static PyObject *
point_item(PyObject* o, gssize i)
{
  PyDiaPoint* self = (PyDiaPoint*)o;

  switch (i) {
  case 0 : return PyFloat_FromDouble(self->pt.x);
  case 1 : return PyFloat_FromDouble(self->pt.y);
  default :
    PyErr_SetString(PyExc_IndexError, "PyDiaPoint index out of range");
    return NULL;
  }
}
static PyObject *
point_slice(PyObject *o, gssize i, gssize j)
{
  PyObject *ret;

  /* j maybe negative */
  if (j <= 0)
    j = 1 + j;
  /* j may be rather huge [:] ^= 0:0x7FFFFFFF */
  if (j > 1)
    j = 1;
  ret = PyTuple_New(j - i + 1);
  if (ret) {
    gssize k;
    for (k = i; k <= j && k < 2; k++)
      PyTuple_SetItem(ret, k - i, point_item(o, k)); 
  }
  return ret;
}

static PySequenceMethods point_as_sequence = {
	point_length, /*sq_length*/
	(binaryfunc)0, /*sq_concat*/
	0, /*sq_repeat*/
	point_item, /*sq_item*/
	point_slice, /*sq_slice*/
	0,		/*sq_ass_item*/
	0,		/*sq_ass_slice*/
	(objobjproc)0 /*sq_contains*/
};

/* Rect */
static gssize
rect_length(PyObject *o)
{
  return 4;
}
static PyObject *
rect_item(PyObject *o, gssize i)
{
  PyDiaRectangle* self = (PyDiaRectangle *)o;

  switch (i) {
  case 0 : return PyDiaRectangle_GetAttr(self, "left");
  case 1 : return PyDiaRectangle_GetAttr(self, "top");
  case 2 : return PyDiaRectangle_GetAttr(self, "right");
  case 3 : return PyDiaRectangle_GetAttr(self, "bottom");
  default :
    PyErr_SetString(PyExc_IndexError, "PyDiaRectangle index out of range");
    return NULL;
  }
}
static PyObject *
rect_slice(PyObject* o, gssize i, gssize j)
{
  PyObject *ret;

  /* j maybe negative */
  if (j <= 0)
    j = 3 + j;
  /* j may be rather huge [:] ^= 0:0x7FFFFFFF */
  if (j > 3)
    j = 3;
  ret = PyTuple_New(j - i + 1);
  if (ret) {
    int k;
    for (k = i; k <= j && k < 4; k++)
      PyTuple_SetItem(ret, k - i, rect_item(o, k)); 
  }
  return ret;
}

static PySequenceMethods rect_as_sequence = {
	rect_length, /*sq_length*/
	(binaryfunc)0, /*sq_concat*/
	0, /*sq_repeat*/
	rect_item, /*sq_item*/
	rect_slice, /*sq_slice*/
	0,		/*sq_ass_item*/
	0,		/*sq_ass_slice*/
	(objobjproc)0 /*sq_contains*/
};

static PyMemberDef PyDiaPoint_Members[] = {
    { "x", T_DOUBLE, offsetof(PyDiaPoint, pt.x), 0,
      "double: coordinate horizontal part" },
    { "y", T_DOUBLE, offsetof(PyDiaPoint, pt.y), 0,
      "double: coordinate vertical part" },
    { NULL }
};
/*
 * Python objetcs
 */
PyTypeObject PyDiaPoint_Type = {
    PyObject_HEAD_INIT(&PyType_Type)
    0,
    "dia.Point",
    sizeof(PyDiaPoint),
    0,
    (destructor)PyDiaGeometry_Dealloc,
    (printfunc)0,
    (getattrfunc)0,
    (setattrfunc)0,
    (cmpfunc)PyDiaPoint_Compare,
    (reprfunc)0,
    0, /* as_number */
    &point_as_sequence,
    0,
    (hashfunc)PyDiaGeometry_Hash,
    (ternaryfunc)0,
    (reprfunc)PyDiaPoint_Str,
    PyObject_GenericGetAttr, /* tp_getattro */
    (setattrofunc)0,
    (PyBufferProcs *)0,
    0L, /* Flags */
    "The dia.Point does not only provide access trough it's members but also via a sequence interface.",
    (traverseproc)0,
    (inquiry)0,
    (richcmpfunc)0,
    0, /* tp_weakliszoffset */
    (getiterfunc)0,
    (iternextfunc)0,
    0, /* tp_methods */
    PyDiaPoint_Members, /* tp_members */
    0
};
#define T_INVALID -1 /* can't allow direct access due to pyobject->is_int */
static PyMemberDef PyDiaRect_Members[] = {
    { "top", T_INVALID, 0, RESTRICTED|READONLY,
      "int or double: upper edge y coordinate" },
    { "left", T_INVALID, 0, RESTRICTED|READONLY,
      "int or double: left edge x coordinate" },
    { "bottom", T_INVALID, 0, RESTRICTED|READONLY,
      "int or double: lower edge y coordinate" },
    { "right", T_INVALID, 0, RESTRICTED|READONLY,
      "int or double: right edge x coordinate" },
    { NULL }
};
PyTypeObject PyDiaRectangle_Type = {
    PyObject_HEAD_INIT(&PyType_Type)
    0,
    "dia.Rectangle",
    sizeof(PyDiaRectangle),
    0,
    (destructor)PyDiaGeometry_Dealloc,
    (printfunc)0,
    (getattrfunc)PyDiaRectangle_GetAttr,
    (setattrfunc)0,
    (cmpfunc)PyDiaRectangle_Compare,
    (reprfunc)0,
    0, /* as_number */
    &rect_as_sequence,
    0, /* as_mapping */
    (hashfunc)PyDiaGeometry_Hash,
    (ternaryfunc)0,
    (reprfunc)PyDiaRectangle_Str,
    (getattrofunc)0,
    (setattrofunc)0,
    (PyBufferProcs *)0,
    0L, /* Flags */
    "The dia.Rectangle does not only provide access trough it's members but also via a sequence interface.",
    (traverseproc)0,
    (inquiry)0,
    (richcmpfunc)0,
    0, /* tp_weakliszoffset */
    (getiterfunc)0,
    (iternextfunc)0,
    0, /* tp_methods */
    PyDiaRect_Members, /* tp_members */
    0
};

static PyMemberDef PyDiaBezPoint_Members[] = {
    { "type", T_INT, offsetof(PyDiaBezPoint, bpn.type), 0,
      "int: MOVETO, LINETO using p1 only;  CURVETO all 3 points" },
    { "p1", T_INVALID, offsetof(PyDiaBezPoint, bpn.p1), 0, /* T_INVALID for Python not knowing Point */
      "Point: first control point for CURVETO" },
    { "p2", T_INVALID, offsetof(PyDiaBezPoint, bpn.p2), 0,
      "Point: second control point for CURVETO" },
    { "p3", T_INVALID, offsetof(PyDiaBezPoint, bpn.p3), 0,
      "Point: target point for CURVETO" },
    { NULL }
};
PyTypeObject PyDiaBezPoint_Type = {
    PyObject_HEAD_INIT(&PyType_Type)
    0,
    "dia.BezPoint",
    sizeof(PyDiaBezPoint),
    0,
    (destructor)PyDiaGeometry_Dealloc,
    (printfunc)0,
    (getattrfunc)PyDiaBezPoint_GetAttr,
    (setattrfunc)0,
    (cmpfunc)PyDiaBezPoint_Compare,
    (reprfunc)0,
    0,
    0,
    0,
    (hashfunc)PyDiaGeometry_Hash,
    (ternaryfunc)0,
    (reprfunc)PyDiaBezPoint_Str,
    (getattrofunc)0,
    (setattrofunc)0,
    (PyBufferProcs *)0,
    0L, /* Flags */
    "A dia.Point, a bezier type and two control points (dia.Point) make a bezier point.",
    (traverseproc)0,
    (inquiry)0,
    (richcmpfunc)0,
    0, /* tp_weakliszoffset */
    (getiterfunc)0,
    (iternextfunc)0,
    0, /* tp_methods */
    PyDiaBezPoint_Members, /* tp_members */
    0
};

static PyMemberDef PyDiaArrow_Members[] = {
    { "type", T_INT, offsetof(PyDiaArrow, arrow.type), 0,
      "int: the shape of the arrow" },
    { "width", T_DOUBLE, offsetof(PyDiaPoint, pt.x), 0,
      "double: corresponding to line width" },
    { "length", T_DOUBLE, offsetof(PyDiaPoint, pt.y), 0,
      "double: length along the line" },
    { NULL }
};
PyTypeObject PyDiaArrow_Type = {
    PyObject_HEAD_INIT(&PyType_Type)
    0,
    "dia.Arrow",
    sizeof(PyDiaArrow),
    0,
    (destructor)PyDiaGeometry_Dealloc,
    (printfunc)0,
    (getattrfunc)0,
    (setattrfunc)0,
    (cmpfunc)PyDiaArrow_Compare,
    (reprfunc)0,
    0,
    0,
    0,
    (hashfunc)PyDiaGeometry_Hash,
    (ternaryfunc)0,
    (reprfunc)PyDiaArrow_Str,
    PyObject_GenericGetAttr, /* tp_getattro */
    (setattrofunc)0,
    (PyBufferProcs *)0,
    0L, /* Flags */
    "Dia's line objects usually ends with an dia.Arrow",
    (traverseproc)0,
    (inquiry)0,
    (richcmpfunc)0,
    0, /* tp_weakliszoffset */
    (getiterfunc)0,
    (iternextfunc)0,
    0, /* tp_methods */
    PyDiaArrow_Members, /* tp_members */
    0
};

static PyMemberDef PyDiaMatrix_Members[] = {
    { "xx", T_DOUBLE, offsetof(PyDiaMatrix, matrix.xx), 0, "double" },
    { "xy", T_DOUBLE, offsetof(PyDiaMatrix, matrix.xy), 0, "double" },
    { "yx", T_DOUBLE, offsetof(PyDiaMatrix, matrix.yx), 0, "double" },
    { "yy", T_DOUBLE, offsetof(PyDiaMatrix, matrix.yy), 0, "double" },
    { "x0", T_DOUBLE, offsetof(PyDiaMatrix, matrix.x0), 0, "double" },
    { "y0", T_DOUBLE, offsetof(PyDiaMatrix, matrix.y0), 0, "double" },
    { NULL }
};
PyTypeObject PyDiaMatrix_Type = {
    PyObject_HEAD_INIT(&PyType_Type)
    0,
    "dia.Matrix",
    sizeof(PyDiaMatrix),
    0,
    (destructor)PyDiaGeometry_Dealloc,
    (printfunc)0,
    (getattrfunc)0,
    (setattrfunc)0,
    (cmpfunc)PyDiaMatrix_Compare,
    (reprfunc)0,
    0,
    0,
    0,
    (hashfunc)PyDiaGeometry_Hash,
    (ternaryfunc)0,
    (reprfunc)PyDiaMatrix_Str,
    PyObject_GenericGetAttr, /* tp_getattro */
    (setattrofunc)0,
    (PyBufferProcs *)0,
    0L, /* Flags */
    "Dia's matrix to do affine transformation",
    (traverseproc)0,
    (inquiry)0,
    (richcmpfunc)0,
    0, /* tp_weakliszoffset */
    (getiterfunc)0,
    (iternextfunc)0,
    0, /* tp_methods */
    PyDiaMatrix_Members, /* tp_members */
    0
};