Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Metaball.c « api2_2x « python « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9cc5aac3d7743bf5673ded41a05c31f472dcb783 (plain)
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
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
/* 
 * $Id$
 *
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * 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.
 *
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 * All rights reserved.
 *
 * This is a new part of Blender.
 *
 * Contributor(s): Jacques Guignot
 *
 * ***** END GPL LICENSE BLOCK *****
 */

#include "Metaball.h" /*This must come first*/

#include "BKE_main.h"
#include "BKE_global.h"
#include "BKE_mball.h"
#include "BKE_library.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h" /* for quat normal */
#include "DNA_object_types.h"
#include "Mathutils.h"
#include "Material.h"
#include "gen_utils.h"
#include "gen_library.h"

/* for dealing with materials */
#include "MEM_guardedalloc.h"
#include "BKE_material.h"

/* checks for the metaelement being removed */
#define METAELEM_DEL_CHECK_PY(bpy_meta_elem) if (!(bpy_meta_elem->metaelem)) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "Metaball has been removed" ) );
#define METAELEM_DEL_CHECK_INT(bpy_meta_elem) if (!(bpy_meta_elem->metaelem)) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "Metaball has been removed" ) );

/*****************************************************************************/
/* Python API function prototypes for the Metaball module.                   */
/*****************************************************************************/
static PyObject *M_Metaball_New( PyObject * self, PyObject * args );
static PyObject *M_Metaball_Get( PyObject * self, PyObject * args );

/*****************************************************************************/
/* The following string definitions are used for documentation strings.      */
/* In Python these will be written to the console when doing a               */
/* Blender.Metaball.__doc__                                                  */
/*****************************************************************************/
static char M_Metaball_doc[] =
	"The Blender Metaball module\n\n\nMetaballs are primitive shapes\
 such as balls, pipes, boxes and planes,\
 that can join each other to create smooth,\
 organic volumes\n. The shapes themseves are called\
 'Metaelements' and can be accessed from the Metaball module.";

static char M_Metaball_New_doc[] = "Creates new metaball object data";

static char M_Metaball_Get_doc[] = "Retreives an existing metaball object data";

/*****************************************************************************/
/* Python method structure definition for Blender.Metaball module:           */
/*****************************************************************************/
struct PyMethodDef M_Metaball_methods[] = {
	{"New", M_Metaball_New, METH_VARARGS, M_Metaball_New_doc},
	{"Get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
	{NULL, NULL, 0, NULL}
};

static PyObject *M_MetaElem_TypesDict( void )
{
	PyObject *Types = PyConstant_New(  );

	if( Types ) {
		BPy_constant *d = ( BPy_constant * ) Types;

		PyConstant_Insert( d, "BALL",	PyInt_FromLong( MB_BALL ) );
		/* PyConstant_Insert( d, "TUBEX",	PyInt_FromLong( MB_TUBEX ) );  - DEPRICATED */
		/* PyConstant_Insert( d, "TUBEY",	PyInt_FromLong( MB_TUBEY ) );  - DEPRICATED */
		/* PyConstant_Insert( d, "TUBEZ",	PyInt_FromLong( MB_TUBEZ ) );  - DEPRICATED */
		PyConstant_Insert( d, "TUBE",	PyInt_FromLong( MB_TUBE ) );
		PyConstant_Insert( d, "PLANE",	PyInt_FromLong( MB_PLANE ) );
		PyConstant_Insert( d, "ELIPSOID",PyInt_FromLong( MB_ELIPSOID ) );
		PyConstant_Insert( d, "CUBE",	PyInt_FromLong( MB_CUBE ) );
	}

	return Types;
}

static PyObject *M_MetaElem_UpdateDict( void )
{
	PyObject *Update = PyConstant_New(  );

	if( Update ) {
		BPy_constant *d = ( BPy_constant * ) Update;
		PyConstant_Insert( d, "ALWAYS",	PyInt_FromLong( MB_UPDATE_ALWAYS ) );
		PyConstant_Insert( d, "HALFRES",PyInt_FromLong( MB_UPDATE_HALFRES ) );
		PyConstant_Insert( d, "FAST",	PyInt_FromLong( MB_UPDATE_FAST ) );
		PyConstant_Insert( d, "NEVER",	PyInt_FromLong( MB_UPDATE_NEVER ) );
	}

	return Update;
}

/*****************************************************************************/
/* Python BPy_Metaball methods declarations:                                */
/*****************************************************************************/
static PyObject *Metaball_getElements( BPy_Metaball * self );
static PyObject *Metaball_getMaterials( BPy_Metaball * self );
static int Metaball_setMaterials( BPy_Metaball * self, PyObject * value );
static PyObject *Metaball_getWiresize( BPy_Metaball * self );
static int Metaball_setWiresize( BPy_Metaball * self, PyObject * value );
static PyObject *Metaball_getRendersize( BPy_Metaball * self );
static int Metaball_setRendersize( BPy_Metaball * self, PyObject * value);
static PyObject *Metaball_getThresh( BPy_Metaball * self );
static int Metaball_setThresh( BPy_Metaball * self, PyObject * args );
static PyObject *Metaball_getUpdate( BPy_Metaball * self );
static int Metaball_setUpdate( BPy_Metaball * self, PyObject * args );
static PyObject *Metaball_copy( BPy_Metaball * self );

/*****************************************************************************/
/* Python BPy_Metaball methods table:                                       */
/*****************************************************************************/
static PyMethodDef BPy_Metaball_methods[] = {
	/* name, method, flags, doc */
	{"__copy__", ( PyCFunction ) Metaball_copy,
	 METH_NOARGS, "() - Return a copy of this metaball"},
	{"copy", ( PyCFunction ) Metaball_copy,
	 METH_NOARGS, "() - Return a copy of this metaball"},
	{NULL, NULL, 0, NULL}
};

/*****************************************************************************/
/* Python BPy_Metaelem methods table:                                        */
/*****************************************************************************/
static PyMethodDef BPy_Metaelem_methods[] = {
	{NULL, NULL, 0, NULL}
};

/*****************************************************************************/
/* Python Metaball_Type callback function prototypes:                       */
/*****************************************************************************/
static PyObject *Metaball_repr( BPy_Metaball * self );
static int Metaball_compare( BPy_Metaball * a, BPy_Metaball * b );

/*****************************************************************************/
/* Python Metaelem_Type callback function prototypes:                        */
/*****************************************************************************/
static void Metaelem_dealloc( BPy_Metaelem * self );
static PyObject *Metaelem_repr( BPy_Metaelem * self );
static int Metaelem_compare( BPy_Metaelem * a, BPy_Metaelem * b );

static PyObject *Metaelem_getType( BPy_Metaelem *self );
static int Metaelem_setType( BPy_Metaelem * self,  PyObject * args );
static PyObject *Metaelem_getCoord( BPy_Metaelem * self );
static int Metaelem_setCoord( BPy_Metaelem * self,  VectorObject * value );
static PyObject *Metaelem_getDims( BPy_Metaelem * self );
static int Metaelem_setDims( BPy_Metaelem * self,  VectorObject * value );
static PyObject *Metaelem_getQuat( BPy_Metaelem * self );
static int Metaelem_setQuat( BPy_Metaelem * self,  QuaternionObject * value );
static PyObject *Metaelem_getStiffness( BPy_Metaelem * self );
static int Metaelem_setStiffness( BPy_Metaelem * self,  PyObject * value );
static PyObject *Metaelem_getRadius( BPy_Metaelem * self );
static int Metaelem_setRadius( BPy_Metaelem * self,  PyObject * value );

static PyObject *Metaelem_getMFlagBits( BPy_Metaelem * self, void * type );
static int Metaelem_setMFlagBits( BPy_Metaelem * self, PyObject * value, void * type );

/*****************************************************************************/
/* Python attributes get/set structure:                                      */
/*****************************************************************************/
static PyGetSetDef BPy_Metaball_getseters[] = {
	GENERIC_LIB_GETSETATTR,
	{"materials",
	 (getter)Metaball_getMaterials, (setter)Metaball_setMaterials,
	 "Number of metaball users",
	 NULL},
	{"elements",
	 (getter)Metaball_getElements, (setter)NULL,
	 "Elements in this metaball",
	 NULL},
	{"wiresize",
	 (getter)Metaball_getWiresize, (setter)Metaball_setWiresize,
	 "The density to draw the metaball in the 3D view",
	 NULL},
	{"rendersize",
	 (getter)Metaball_getRendersize, (setter)Metaball_setRendersize,
	 "The density to render wire",
	 NULL},
	{"thresh",
	 (getter)Metaball_getThresh, (setter)Metaball_setThresh,
	 "The density to render wire",
	 NULL},
	{"update",
	 (getter)Metaball_getUpdate, (setter)Metaball_setUpdate,
	 "The setting for updating this metaball data",
	 NULL},
	{NULL,NULL,NULL,NULL,NULL}  /* Sentinel */
};


/*****************************************************************************/
/* Python TypeMetaball structure definition:                                     */
/*****************************************************************************/
PyTypeObject Metaball_Type = {
	PyObject_HEAD_INIT( NULL )  /* required py macro */
	0,                          /* ob_size */
	/*  For printing, in format "<module>.<name>" */
	"Blender Metaball",             /* char *tp_name; */
	sizeof( BPy_Metaball ),         /* int tp_basicsize; */
	0,                          /* tp_itemsize;  For allocation */

	/* Methods to implement standard operations */

	NULL,						/* destructor tp_dealloc; */
	NULL,                       /* printfunc tp_print; */
	NULL,                       /* getattrfunc tp_getattr; */
	NULL,                       /* setattrfunc tp_setattr; */
	( cmpfunc ) Metaball_compare,   /* cmpfunc tp_compare; */
	( reprfunc ) Metaball_repr,     /* reprfunc tp_repr; */

	/* Method suites for standard classes */

	NULL,                       /* PyNumberMethods *tp_as_number; */
	NULL,                       /* PySequenceMethods *tp_as_sequence; */
	NULL,                       /* PyMappingMethods *tp_as_mapping; */

	/* More standard operations (here for binary compatibility) */

	( hashfunc ) GenericLib_hash,	/* hashfunc tp_hash; */
	NULL,                       /* ternaryfunc tp_call; */
	NULL,                       /* reprfunc tp_str; */
	NULL,                       /* getattrofunc tp_getattro; */
	NULL,                       /* setattrofunc tp_setattro; */

	/* Functions to access object as input/output buffer */
	NULL,                       /* PyBufferProcs *tp_as_buffer; */

  /*** Flags to define presence of optional/expanded features ***/
	Py_TPFLAGS_DEFAULT,         /* long tp_flags; */

	NULL,                       /*  char *tp_doc;  Documentation string */
  /*** Assigned meaning in release 2.0 ***/
	/* call function for all accessible objects */
	NULL,                       /* traverseproc tp_traverse; */

	/* delete references to contained objects */
	NULL,                       /* inquiry tp_clear; */

  /***  Assigned meaning in release 2.1 ***/
  /*** rich comparisons ***/
	NULL,                       /* richcmpfunc tp_richcompare; */

  /***  weak reference enabler ***/
	0,                          /* long tp_weaklistoffset; */

  /*** Added in release 2.2 ***/
	/*   Iterators */
	NULL,                       /* getiterfunc tp_iter; */
	NULL,                       /* iternextfunc tp_iternext; */

  /*** Attribute descriptor and subclassing stuff ***/
	BPy_Metaball_methods,           /* struct PyMethodDef *tp_methods; */
	NULL,                       /* struct PyMemberDef *tp_members; */
	BPy_Metaball_getseters,         /* struct PyGetSetDef *tp_getset; */
	NULL,                       /* struct _typeobject *tp_base; */
	NULL,                       /* PyObject *tp_dict; */
	NULL,                       /* descrgetfunc tp_descr_get; */
	NULL,                       /* descrsetfunc tp_descr_set; */
	0,                          /* long tp_dictoffset; */
	NULL,                       /* initproc tp_init; */
	NULL,                       /* allocfunc tp_alloc; */
	NULL,                       /* newfunc tp_new; */
	/*  Low-level free-memory routine */
	NULL,                       /* freefunc tp_free;  */
	/* For PyObject_IS_GC */
	NULL,                       /* inquiry tp_is_gc;  */
	NULL,                       /* PyObject *tp_bases; */
	/* method resolution order */
	NULL,                       /* PyObject *tp_mro;  */
	NULL,                       /* PyObject *tp_cache; */
	NULL,                       /* PyObject *tp_subclasses; */
	NULL,                       /* PyObject *tp_weaklist; */
	NULL
};


static PyGetSetDef BPy_Metaelem_getseters[] = {
	{"type",
	 (getter)Metaelem_getType, (setter)Metaelem_setType,
	 "Metaelem Type",
	 NULL},
	{"co",
	 (getter)Metaelem_getCoord, (setter)Metaelem_setCoord,
	 "Metaelem Location",
	 NULL},
	{"quat",
	 (getter)Metaelem_getQuat, (setter)Metaelem_setQuat,
	 "Metaelem Rotation Quat",
	 NULL},
	{"dims",
	 (getter)Metaelem_getDims, (setter)Metaelem_setDims,
	 "Metaelem Dimensions",
	 NULL},
	{"stiffness",
	 (getter)Metaelem_getStiffness, (setter)Metaelem_setStiffness,
	 "MetaElem stiffness",
	 NULL},
	{"radius",
	 (getter)Metaelem_getRadius, (setter)Metaelem_setRadius,
	 "The radius of the MetaElem",
	 NULL},
	{"negative",
	 (getter)Metaelem_getMFlagBits, (setter)Metaelem_setMFlagBits,
	 "The density to render wire",
	 (void *)MB_NEGATIVE},
	{"hide",
	 (getter)Metaelem_getMFlagBits, (setter)Metaelem_setMFlagBits,
	 "The density to render wire",
	 (void *)MB_HIDE},
	{NULL,NULL,NULL,NULL,NULL}  /* Sentinel */
};


/*****************************************************************************/
/* Python TypeMetaelem structure definition:                                     */
/*****************************************************************************/
PyTypeObject Metaelem_Type = {
	PyObject_HEAD_INIT( NULL )  /* required py macro */
	0,                          /* ob_size */
	/*  For printing, in format "<module>.<name>" */
	"Blender Metaelem",             /* char *tp_name; */
	sizeof( BPy_Metaelem ),         /* int tp_basicsize; */
	0,                          /* tp_itemsize;  For allocation */

	/* Methods to implement standard operations */

	( destructor ) Metaelem_dealloc,/* destructor tp_dealloc; */
	NULL,                       /* printfunc tp_print; */
	NULL,                       /* getattrfunc tp_getattr; */
	NULL,                       /* setattrfunc tp_setattr; */
	( cmpfunc ) Metaelem_compare,   /* cmpfunc tp_compare; */
	( reprfunc ) Metaelem_repr,     /* reprfunc tp_repr; */

	/* Method suites for standard classes */

	NULL,                       /* PyNumberMethods *tp_as_number; */
	NULL,                       /* PySequenceMethods *tp_as_sequence; */
	NULL,                       /* PyMappingMethods *tp_as_mapping; */

	/* More standard operations (here for binary compatibility) */

	NULL,                       /* hashfunc tp_hash; */
	NULL,                       /* ternaryfunc tp_call; */
	NULL,                       /* reprfunc tp_str; */
	NULL,                       /* getattrofunc tp_getattro; */
	NULL,                       /* setattrofunc tp_setattro; */

	/* Functions to access object as input/output buffer */
	NULL,                       /* PyBufferProcs *tp_as_buffer; */

  /*** Flags to define presence of optional/expanded features ***/
	Py_TPFLAGS_DEFAULT,         /* long tp_flags; */

	NULL,                       /*  char *tp_doc;  Documentation string */
  /*** Assigned meaning in release 2.0 ***/
	/* call function for all accessible objects */
	NULL,                       /* traverseproc tp_traverse; */

	/* delete references to contained objects */
	NULL,                       /* inquiry tp_clear; */

  /***  Assigned meaning in release 2.1 ***/
  /*** rich comparisons ***/
	NULL,                       /* richcmpfunc tp_richcompare; */

  /***  weak reference enabler ***/
	0,                          /* long tp_weaklistoffset; */

  /*** Added in release 2.2 ***/
	/*   Iterators */
	NULL,                       /* getiterfunc tp_iter; */
	NULL,                       /* iternextfunc tp_iternext; */

  /*** Attribute descriptor and subclassing stuff ***/
	BPy_Metaelem_methods,           /* struct PyMethodDef *tp_methods; */
	NULL,                       /* struct PyMemberDef *tp_members; */
	BPy_Metaelem_getseters,         /* struct PyGetSetDef *tp_getset; */
	NULL,                       /* struct _typeobject *tp_base; */
	NULL,                       /* PyObject *tp_dict; */
	NULL,                       /* descrgetfunc tp_descr_get; */
	NULL,                       /* descrsetfunc tp_descr_set; */
	0,                          /* long tp_dictoffset; */
	NULL,                       /* initproc tp_init; */
	NULL,                       /* allocfunc tp_alloc; */
	NULL,                       /* newfunc tp_new; */
	/*  Low-level free-memory routine */
	NULL,                       /* freefunc tp_free;  */
	/* For PyObject_IS_GC */
	NULL,                       /* inquiry tp_is_gc;  */
	NULL,                       /* PyObject *tp_bases; */
	/* method resolution order */
	NULL,                       /* PyObject *tp_mro;  */
	NULL,                       /* PyObject *tp_cache; */
	NULL,                       /* PyObject *tp_subclasses; */
	NULL,                       /* PyObject *tp_weaklist; */
	NULL
};


/*****************************************************************************/
/* Function:              M_Metaball_New                                     */
/* Python equivalent:     Blender.Metaball.New                               */
/*****************************************************************************/
static PyObject *M_Metaball_New( PyObject * self, PyObject * args )
{
	char *name = 0;
	BPy_Metaball *pymball;	/* for Data object wrapper in Python */
	MetaBall *blmball;	/* for actual Data we create in Blender */
	
	if( !PyArg_ParseTuple( args, "|s", &name ) )
		return ( EXPP_ReturnPyObjError( PyExc_TypeError,
						"Metaball.New() - expected string argument (or nothing)" ) );

	/* first create the MetaBall Data in Blender */
	if (name)
		blmball = add_mball( name );
	else
		blmball = add_mball( "Meta" );

	if( blmball ) {
		/* return user count to zero since add_mball() incref'ed it */
		blmball->id.us = 0;
		/* now create the wrapper obj in Python */
		pymball =
			( BPy_Metaball * ) PyObject_NEW( BPy_Metaball,
							 &Metaball_Type );
	} else
		return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
						"Metaball.New() - couldn't create data in Blender" ) );

	if( pymball == NULL )
		return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
						"couldn't create MetaBall Data object" ) );

	pymball->metaball = blmball;
	/*link Python mballer wrapper to Blender MetaBall */
	
	return ( PyObject * ) pymball;
}


/*****************************************************************************/
/* Function:             M_Metaball_Get                                     */
/* Python equivalent:    Blender.Metaball.Get                               */
/* Description:          Receives a string and returns the metaball data obj */
/*                       whose name matches the string.  If no argument is  */
/*                       passed in, a list of all metaball data names in the */
/*                       current scene is returned.                         */
/*****************************************************************************/
static PyObject *M_Metaball_Get( PyObject * self, PyObject * args )
{
	char *name = NULL;
	MetaBall *mball_iter = NULL;

	if( !PyArg_ParseTuple( args, "|s", &name ) )
		return ( EXPP_ReturnPyObjError( PyExc_TypeError,
						"Metaball.Get() - expected string argument (or nothing)" ) );

	if( name ) {		/* (name) - Search mball by name */
		mball_iter = ( MetaBall * ) GetIdFromList( &( G.main->mball ), name );
		
		if (!mball_iter) {
			char error_msg[128];
			PyOS_snprintf( error_msg, sizeof( error_msg ),
				       "Metaball.Get(\"%s\") - not found", name );
			return ( EXPP_ReturnPyObjError
				 ( PyExc_NameError, error_msg ) );
		}
		return Metaball_CreatePyObject(mball_iter);
	
	} else {			/* () - return a list of all mballs in the scene */
		
		PyObject *mballlist = PyList_New( BLI_countlist( &( G.main->mball ) ) );
		int index=0;
		
		if( mballlist == NULL )
			return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
							"MetaBall.Get() - couldn't create PyList" ) );
		
		mball_iter = G.main->mball.first;
		while( mball_iter ) {
			PyList_SetItem( mballlist, index, Metaball_CreatePyObject(mball_iter) );
			index++;
			mball_iter = mball_iter->id.next;
		}
		return mballlist;
	}

}


/*****************************************************************************/
/* Function:	 initObject						*/
/*****************************************************************************/
PyObject *Metaball_Init( void )
{
	PyObject *submodule;
	PyObject *Types=	M_MetaElem_TypesDict( );
	PyObject *Update=	M_MetaElem_UpdateDict( );
	
	if( PyType_Ready( &Metaball_Type ) < 0 )
		return NULL;
	if( PyType_Ready( &Metaelem_Type ) < 0 )
		return NULL;
	if( PyType_Ready( &MetaElemSeq_Type ) < 0 )
		return NULL;
	
	submodule = Py_InitModule3( "Blender.Metaball", M_Metaball_methods, M_Metaball_doc);

	if( Types )
		PyModule_AddObject( submodule, "Types", Types );
		PyModule_AddObject( submodule, "Update", Update );
	
	/*Add SUBMODULES to the module*/
	/*PyDict_SetItemString(dict, "Constraint", Constraint_Init()); */ /*creates a *new* module*/
	return submodule;
}

MetaBall *Metaball_FromPyObject( PyObject * pyobj )
{
	return ( ( BPy_Metaball * ) pyobj )->metaball;
}

static PyObject *Metaball_getMaterials( BPy_Metaball *self )
{
	return EXPP_PyList_fromMaterialList( self->metaball->mat,
			self->metaball->totcol, 1 );
}
static int Metaball_setMaterials( BPy_Metaball *self, PyObject * value )
{
    Material **matlist;
	int len;

    if( !PySequence_Check( value ) ||
			!EXPP_check_sequence_consistency( value, &Material_Type ) )
        return EXPP_ReturnIntError( PyExc_TypeError,
                  "metaball.materials - list should only contain materials or None)" );

    len = PyList_Size( value );
    if( len > 16 )
        return EXPP_ReturnIntError( PyExc_TypeError,
                          "metaball.materials - list can't have more than 16 materials" );

	/* free old material list (if it exists) and adjust user counts */
	if( self->metaball->mat ) {
		MetaBall *mb = self->metaball;
		int i;
		for( i = mb->totcol; i-- > 0; )
			if( mb->mat[i] )
           		mb->mat[i]->id.us--;
		MEM_freeN( mb->mat );
	}

	/* build the new material list, increment user count, store it */

	matlist = EXPP_newMaterialList_fromPyList( value );
	EXPP_incr_mats_us( matlist, len );
	self->metaball->mat = matlist;
    	self->metaball->totcol = (short)len;

/**@ This is another ugly fix due to the weird material handling of blender.
    * it makes sure that object material lists get updated (by their length)
    * according to their data material lists, otherwise blender crashes.
    * It just stupidly runs through all objects...BAD BAD BAD.
    */

    	test_object_materials( ( ID * ) self->metaball );

	return 0;
}

static PyObject *Metaball_getWiresize( BPy_Metaball * self )
{
	return PyFloat_FromDouble( self->metaball->wiresize );
}

static int Metaball_setWiresize( BPy_Metaball * self, PyObject * value )
{
	float param;
	if( !PyNumber_Check( value ) )
		return EXPP_ReturnIntError( PyExc_TypeError,
					"metaball.wiresize - expected float argument" );

	param = (float)PyFloat_AsDouble( value );

	self->metaball->wiresize = EXPP_ClampFloat(param, 0.05f, 1.0);
	return 0;

}
static PyObject *Metaball_getRendersize( BPy_Metaball * self )
{
	return PyFloat_FromDouble( self->metaball->rendersize );
}

static int Metaball_setRendersize( BPy_Metaball * self, PyObject * value )
{

	float param;
	if( !PyNumber_Check( value ) )
		return EXPP_ReturnIntError( PyExc_TypeError,
					"metaball.rendersize - expected float argument" );

	param = (float)PyFloat_AsDouble( value );

	self->metaball->rendersize = EXPP_ClampFloat(param, 0.05f, 1.0);
	return 0;
}

static PyObject *Metaball_getThresh( BPy_Metaball * self )
{
	return PyFloat_FromDouble( self->metaball->thresh );
}

static int Metaball_setThresh( BPy_Metaball * self, PyObject * value )
{

	float param;
	if( !PyNumber_Check( value ) )
		return EXPP_ReturnIntError( PyExc_TypeError,
					"metaball.thresh - expected float argument" );

	param = (float)PyFloat_AsDouble( value );

	self->metaball->thresh = EXPP_ClampFloat(param, 0.0, 5.0);
	return 0;
}

static PyObject *Metaball_getUpdate( BPy_Metaball * self )
{
	return PyInt_FromLong( (long)self->metaball->flag );
}

static int Metaball_setUpdate( BPy_Metaball * self, PyObject * value )
{

	int param;
	if( !PyInt_Check( value ) )
		return EXPP_ReturnIntError( PyExc_TypeError,
					"metaball.update - expected an int argument" );

	param = (int)PyInt_AS_LONG( value );

	self->metaball->flag = EXPP_ClampInt( param, 0, 3 );
	return 0;
}

static PyObject *Metaball_copy( BPy_Metaball * self )
{
	BPy_Metaball *pymball;	/* for Data object wrapper in Python */
	MetaBall *blmball;	/* for actual Data we create in Blender */
	
	blmball = copy_mball( self->metaball );	/* first create the MetaBall Data in Blender */

	if( blmball ) {
		/* return user count to zero since add_mball() incref'ed it */
		blmball->id.us = 0;
		/* now create the wrapper obj in Python */
		pymball =
			( BPy_Metaball * ) PyObject_NEW( BPy_Metaball,
							 &Metaball_Type );
	} else
		return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
						"metaball.__copy__() - couldn't create data in Blender" ) );

	if( pymball == NULL )
		return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
						"metaball.__copy__() - couldn't create data in Blender" ) );

	pymball->metaball = blmball;
	
	return ( PyObject * ) pymball;
}


/* These are needed by Object.c */
PyObject *Metaball_CreatePyObject( MetaBall * mball)
{
	BPy_Metaball *py_mball= PyObject_NEW( BPy_Metaball, &Metaball_Type );

	if( !py_mball )
		return EXPP_ReturnPyObjError( PyExc_MemoryError,
				"couldn't create BPy_Metaball object" );

	py_mball->metaball= mball;

	return ( PyObject * ) py_mball;
}


static PyObject *MetaElemSeq_CreatePyObject(BPy_Metaball *self, MetaElem *iter)
{
	BPy_MetaElemSeq *seq = PyObject_NEW( BPy_MetaElemSeq, &MetaElemSeq_Type);
	seq->bpymetaball = self; Py_INCREF(self);
	seq->iter= iter;
	return (PyObject *)seq;
}

/*
 * Element, get an instance of the iterator.
 */
static PyObject *Metaball_getElements( BPy_Metaball * self )
{
	return MetaElemSeq_CreatePyObject(self, NULL);
}

/*
 * Metaelem dealloc - free from memory
 */
/* This is a callback function for the BPy_Metaelem type. It is */
static void Metaelem_dealloc( BPy_Metaelem * self )
{
	self->metaelem= NULL; /* so any references to the same bpyobject will raise an error */
	PyObject_DEL( self );
}

/*
 * elem.type - int to set the shape of the element
 */
static PyObject *Metaelem_getType( BPy_Metaelem *self )
{	
	METAELEM_DEL_CHECK_PY(self);
	
	return PyInt_FromLong( self->metaelem->type );
}
static int Metaelem_setType( BPy_Metaelem * self,  PyObject * value )
{
	int type;
	if( !PyInt_Check( value ) )
		return EXPP_ReturnIntError( PyExc_TypeError,
			"metaelem.type - expected an integer (bitmask) as argument" );
	
	METAELEM_DEL_CHECK_INT(self);
	
	type = PyInt_AS_LONG( value );
	
	if( (type < 0) || ( type > ( MB_BALL | MB_TUBEX | MB_TUBEY | MB_TUBEZ | MB_TUBE | MB_PLANE | MB_ELIPSOID | MB_CUBE ) ))
		return EXPP_ReturnIntError( PyExc_ValueError,
					      "metaelem.type - value out of range" );
	
	self->metaelem->type= type;
	return 0;
}

/*
 * elem.co - non wrapped vector representing location
 */
static PyObject *Metaelem_getCoord( BPy_Metaelem * self )
{
	float co[3];
	
	METAELEM_DEL_CHECK_PY(self);
	
	co[0]= self->metaelem->x;
	co[1]= self->metaelem->y;
	co[2]= self->metaelem->z;
	
	return newVectorObject( co, 3, Py_NEW );
}
static int Metaelem_setCoord( BPy_Metaelem * self,  VectorObject * value )
{

	if( !VectorObject_Check( value ) || value->size != 3 )
		return EXPP_ReturnIntError( PyExc_TypeError,
				"metaelem.co - expected vector argument of size 3" );
	
	METAELEM_DEL_CHECK_INT(self);
	
	self->metaelem->x= value->vec[0];
	self->metaelem->y= value->vec[1];
	self->metaelem->z= value->vec[2];
	return 0;
}

/*
 * elem.dims - non wrapped vector representing the xyz dimensions
 * only effects some element types
 */
static PyObject *Metaelem_getDims( BPy_Metaelem * self )
{
	float co[3];
	METAELEM_DEL_CHECK_PY(self);
	
	co[0]= self->metaelem->expx;
	co[1]= self->metaelem->expy;
	co[2]= self->metaelem->expz;
	return newVectorObject( co, 3, Py_NEW );
}
static int Metaelem_setDims( BPy_Metaelem * self,  VectorObject * value )
{
	if( !VectorObject_Check( value ) || value->size != 3 )
		return EXPP_ReturnIntError( PyExc_TypeError,
				"metaelem.dims - expected vector argument of size 3" );

	METAELEM_DEL_CHECK_INT(self);
	
	self->metaelem->expx= EXPP_ClampFloat(value->vec[0], 0.0, 20.0);
	self->metaelem->expy= EXPP_ClampFloat(value->vec[1], 0.0, 20.0);
	self->metaelem->expz= EXPP_ClampFloat(value->vec[2], 0.0, 20.0);
	return 0;
}

/*
 * elem.quat - non wrapped quat representing the rotation
 * only effects some element types - a rotated ball has no effect for eg.
 */
static PyObject *Metaelem_getQuat( BPy_Metaelem * self )
{
	METAELEM_DEL_CHECK_PY(self);
	return newQuaternionObject(self->metaelem->quat, Py_NEW); 
}
static int Metaelem_setQuat( BPy_Metaelem * self,  QuaternionObject * value )
{
	int i;
	if( !QuaternionObject_Check( value ) )
		return EXPP_ReturnIntError( PyExc_TypeError,
				"metaelem.quat - expected quat argument" );
	
	METAELEM_DEL_CHECK_INT(self);
	
	for (i = 0; i < 4; i++)
		self->metaelem->quat[i]= value->quat[i];
	
	/* need to normalize or metaball drawing can go into an infinate loop */
	NormalQuat(self->metaelem->quat);
	
	return 0;
}

/*
 * elem.hide and elem.sel - get/set true false
 */
static PyObject *Metaelem_getMFlagBits( BPy_Metaelem * self, void * type )
{
	METAELEM_DEL_CHECK_PY(self);
	return EXPP_getBitfield( &(self->metaelem->flag), (int)((long)type ), 'h' );
}
static int Metaelem_setMFlagBits( BPy_Metaelem * self, PyObject * value,
		void * type )
{
	METAELEM_DEL_CHECK_INT(self);
	return EXPP_setBitfield( value, &(self->metaelem->flag), 
			(int)((long)type), 'h' );
}

/*
 * elem.stiffness - floating point, the volume of this element.
 */
static PyObject *Metaelem_getStiffness( BPy_Metaelem *self )
{
	METAELEM_DEL_CHECK_PY(self);
	return PyFloat_FromDouble( self->metaelem->s );
}
static int Metaelem_setStiffness( BPy_Metaelem *self, PyObject *value)
{
	if( !PyNumber_Check( value ) )
		return EXPP_ReturnIntError( PyExc_TypeError,
					"metaelem.stiffness - expected float argument" );

	self->metaelem->s = EXPP_ClampFloat((float)PyFloat_AsDouble( value ), 0.0, 10.0);
	return 0;
}

/*
 * elem.radius- floating point, the size if the element
 */
static PyObject *Metaelem_getRadius( BPy_Metaelem *self )
{
	METAELEM_DEL_CHECK_PY(self);
	return PyFloat_FromDouble( self->metaelem->rad );
}
static int Metaelem_setRadius( BPy_Metaelem *self, PyObject *value)
{
	if( !PyNumber_Check( value ) )
		return EXPP_ReturnIntError( PyExc_TypeError,
					"metaelem.radius - expected float argument" );

	self->metaelem->rad = /* is 5000 too small? */
			EXPP_ClampFloat((float)PyFloat_AsDouble( value ), 0.0, 5000.0);
	
	return 0;
}


/*
 * callback functions for comparison.
 * It compares two Metaball_Type objects. Only the "==" and "!="
 * comparisons are meaninful. Returns 0 for equality and -1 if
 * they don't point to the same Blender struct.
 * In Python it becomes 1 if they are equal, 0 otherwise.	
 */
static int Metaball_compare( BPy_Metaball * a, BPy_Metaball * b )
{
	MetaBall *pa = a->metaball, *pb = b->metaball;
	return ( pa == pb ) ? 0 : -1;
}

static int MetaElemSeq_compare( BPy_MetaElemSeq * a, BPy_MetaElemSeq * b )
{
	MetaBall *pa = a->bpymetaball->metaball, *pb = b->bpymetaball->metaball;
	return ( pa == pb ) ? 0 : -1;
}

static int Metaelem_compare( BPy_Metaelem * a, BPy_Metaelem * b )
{
	MetaElem *pa = a->metaelem, *pb = b->metaelem;
	return ( pa == pb ) ? 0 : -1;
}

/*
 * repr function
 * callback functions building meaninful string to representations
 */
static PyObject *Metaball_repr( BPy_Metaball * self )
{
	return PyString_FromFormat( "[Metaball \"%s\"]",
				    self->metaball->id.name + 2 );
}

static PyObject *Metaelem_repr( BPy_Metaelem * self )
{
	return PyString_FromString( "Metaelem" );
}

static PyObject *MetaElemSeq_repr( BPy_MetaElemSeq * self )
{
	return PyString_FromFormat( "[Metaball Iterator \"%s\"]",
				    self->bpymetaball->metaball->id.name + 2 );
}



/*
 * MeteElem Seq sequence 
 */

static PyObject *MetaElem_CreatePyObject( MetaElem *metaelem )
{
	BPy_Metaelem *elem= PyObject_NEW( BPy_Metaelem, &Metaelem_Type);
	elem->metaelem = metaelem; Py_INCREF(elem);
	return (PyObject *)elem;
}

static int MetaElemSeq_len( BPy_MetaElemSeq * self )
{
	return BLI_countlist( &( self->bpymetaball->metaball->elems ) );
}


static PySequenceMethods MetaElemSeq_as_sequence = {
	( inquiry ) MetaElemSeq_len,	/* sq_length */
	( binaryfunc ) 0,	/* sq_concat */
	( intargfunc ) 0,	/* sq_repeat */
	( intargfunc ) 0,	/* sq_item */
	( intintargfunc ) 0,	/* sq_slice */
	( intobjargproc ) 0,	/* sq_ass_item */
	( intintobjargproc ) 0,	/* sq_ass_slice */
	0,0,0,
};

/************************************************************************
 *
 * Python MetaElemSeq_Type iterator (iterates over Metaballs)
 *
 ************************************************************************/

/*
 * Initialize the interator
 */

static PyObject *MetaElemSeq_getIter( BPy_MetaElemSeq * self )
{
	if (!self->iter) { /* not alredy looping on this data, */
		self->iter = self->bpymetaball->metaball->elems.first;
		return EXPP_incr_ret ( (PyObject *) self );
	} else
		return MetaElemSeq_CreatePyObject(self->bpymetaball, self->bpymetaball->metaball->elems.first);
}

/*
 * Return next MetaElem.
 */

static PyObject *MetaElemSeq_nextIter( BPy_MetaElemSeq * self )
{
	PyObject *object;
	if( !(self->iter) ||  !(self->bpymetaball->metaball) ) {
		self->iter= NULL;
		return EXPP_ReturnPyObjError( PyExc_StopIteration,
				"iterator at end" );
	}
	
	object= MetaElem_CreatePyObject( self->iter ); 
	self->iter= self->iter->next;
	return object;
}

/*
 * Adds and returns a new metaelement, 
 * no args are taken so the returned metaball must be modified after adding.
 * Accessed as mball.elements.add() where mball is a python metaball data type.
 */
static PyObject *MetaElemSeq_add( BPy_MetaElemSeq * self )
{
	MetaElem *ml;

	ml = MEM_callocN( sizeof( MetaElem ), "metaelem" );
	BLI_addhead( &( self->bpymetaball->metaball->elems ), ml );
	ml->x = 0;
	ml->y = 0;
	ml->z = 0;
	ml->quat[0]= 1.0;
	ml->quat[1]= 0.0;
	ml->quat[2]= 0.0;
	ml->quat[3]= 0.0;
	ml->rad = 2;
	ml->s = 2.0;
	ml->flag = SELECT;
	ml->type = 0;
	ml->expx = 1;
	ml->expy = 1;
	ml->expz = 1;
	ml->type = MB_BALL;

	return MetaElem_CreatePyObject(ml);
}


/*
 * removes a metaelement if it is a part of the metaball, 
 * no args are taken so the returned metaball must be modified after adding.
 * Accessed as mball.elements.add() where mball is a python metaball data type.
 */
static PyObject *MetaElemSeq_remove( BPy_MetaElemSeq * self, BPy_Metaelem *elem )
{
	MetaElem *ml_iter, *ml_py;
	
	if( !BPy_Metaelem_Check(elem) )
		return EXPP_ReturnPyObjError( PyExc_TypeError,
			"elements.remove(metaelem) - expected a Metaball element" );
	
	METAELEM_DEL_CHECK_PY(elem);
	
	ml_py= elem->metaelem;
	
	for (ml_iter= self->bpymetaball->metaball->elems.first; ml_iter; ml_iter= ml_iter->next) {
		if (ml_py == ml_iter) {
			elem->metaelem= NULL;
			BLI_freelinkN( &(self->bpymetaball->metaball->elems), ml_py);
			Py_RETURN_NONE;
		}
	}
	
	return EXPP_ReturnPyObjError( PyExc_ValueError,
		"elements.remove(elem): elem not in meta elements" );	
	
}

static struct PyMethodDef BPy_MetaElemSeq_methods[] = {
	{"add", (PyCFunction)MetaElemSeq_add, METH_NOARGS,
		"add metaelem to metaball data"},
	{"remove", (PyCFunction)MetaElemSeq_remove, METH_O,
		"remove element from metaball data"},
	{NULL, NULL, 0, NULL}
};

/************************************************************************
 *
 * Python MetaElemSeq_Type standard operations
 *
 ************************************************************************/

static void MetaElemSeq_dealloc( BPy_MetaElemSeq * self )
{
	Py_DECREF(self->bpymetaball);
	PyObject_DEL( self );
}

/*****************************************************************************/
/* Python MetaElemSeq_Type structure definition:                               */
/*****************************************************************************/
PyTypeObject MetaElemSeq_Type = {
	PyObject_HEAD_INIT( NULL )  /* required py macro */
	0,                          /* ob_size */
	/*  For printing, in format "<module>.<name>" */
	"Blender MetaElemSeq",           /* char *tp_name; */
	sizeof( BPy_MetaElemSeq ),       /* int tp_basicsize; */
	0,                          /* tp_itemsize;  For allocation */

	/* Methods to implement standard operations */

	( destructor ) MetaElemSeq_dealloc,/* destructor tp_dealloc; */
	NULL,                       /* printfunc tp_print; */
	NULL,                       /* getattrfunc tp_getattr; */
	NULL,                       /* setattrfunc tp_setattr; */
	( cmpfunc ) MetaElemSeq_compare,   /* cmpfunc tp_compare; */
	( reprfunc ) MetaElemSeq_repr,     /* reprfunc tp_repr; */

	/* Method suites for standard classes */

	NULL,                       /* PyNumberMethods *tp_as_number; */
	&MetaElemSeq_as_sequence,	    /* PySequenceMethods *tp_as_sequence; */
	NULL,                       /* PyMappingMethods *tp_as_mapping; */

	/* More standard operations (here for binary compatibility) */

	NULL,                       /* hashfunc tp_hash; */
	NULL,                       /* ternaryfunc tp_call; */
	NULL,                       /* reprfunc tp_str; */
	NULL,                       /* getattrofunc tp_getattro; */
	NULL,                       /* setattrofunc tp_setattro; */

	/* Functions to access object as input/output buffer */
	NULL,                       /* PyBufferProcs *tp_as_buffer; */

  /*** Flags to define presence of optional/expanded features ***/
	Py_TPFLAGS_DEFAULT,         /* long tp_flags; */

	NULL,                       /*  char *tp_doc;  Documentation string */
  /*** Assigned meaning in release 2.0 ***/
	/* call function for all accessible objects */
	NULL,                       /* traverseproc tp_traverse; */

	/* delete references to contained objects */
	NULL,                       /* inquiry tp_clear; */

  /***  Assigned meaning in release 2.1 ***/
  /*** rich comparisons ***/
	NULL,                       /* richcmpfunc tp_richcompare; */

  /***  weak reference enabler ***/
	0,                          /* long tp_weaklistoffset; */

  /*** Added in release 2.2 ***/
	/*   Iterators */
	( getiterfunc) MetaElemSeq_getIter, /* getiterfunc tp_iter; */
	( iternextfunc ) MetaElemSeq_nextIter, /* iternextfunc tp_iternext; */

  /*** Attribute descriptor and subclassing stuff ***/
	BPy_MetaElemSeq_methods,       /* struct PyMethodDef *tp_methods; */
	NULL,                       /* struct PyMemberDef *tp_members; */
	NULL,                       /* struct PyGetSetDef *tp_getset; */
	NULL,                       /* struct _typeobject *tp_base; */
	NULL,                       /* PyObject *tp_dict; */
	NULL,                       /* descrgetfunc tp_descr_get; */
	NULL,                       /* descrsetfunc tp_descr_set; */
	0,                          /* long tp_dictoffset; */
	NULL,                       /* initproc tp_init; */
	NULL,                       /* allocfunc tp_alloc; */
	NULL,                       /* newfunc tp_new; */
	/*  Low-level free-memory routine */
	NULL,                       /* freefunc tp_free;  */
	/* For PyObject_IS_GC */
	NULL,                       /* inquiry tp_is_gc;  */
	NULL,                       /* PyObject *tp_bases; */
	/* method resolution order */
	NULL,                       /* PyObject *tp_mro;  */
	NULL,                       /* PyObject *tp_cache; */
	NULL,                       /* PyObject *tp_subclasses; */
	NULL,                       /* PyObject *tp_weaklist; */
	NULL
};