[Zodb-checkins] CVS: Zope/lib/Components/ExtensionClass/src - ExtensionClass.h:1.16.140.1

Matthew T. Kromer matt@zope.com
Tue, 11 Dec 2001 16:29:18 -0500


Update of /cvs-repository/Zope/lib/Components/ExtensionClass/src
In directory cvs.zope.org:/tmp/cvs-serv7909/lib/Components/ExtensionClass/src

Modified Files:
      Tag: matt-stability-branch
	ExtensionClass.h 
Log Message:
Modify ExtensionClass.h to align with the python 2.1 type headers (ie add the
extra fields before the extensionclass specific fields).  This includes a bit
of bogosity in the METHOD_CHAIN macro to add the extra NULL fields, but works
OK since METHOD_CHAIN is only used in large statruct initializers in the Zope
code base.

The belief is that aligning the fields may help reduce possible problems by
things doing something they shouldn't with ExtensionClass private data which
they thought was part of the 2.1 type header, if something failed to respect
a type flag indicating the presence of the optional data.


=== Zope/lib/Components/ExtensionClass/src/ExtensionClass.h 1.16 => 1.16.140.1 ===
 	setattrofunc tp_setattro;
 	/* Space for future expansion */
-	long tp_xxx3;
-	long tp_xxx4;
+	PyBufferProcs	*tp_as_buffer;
+	long tp_flags;
 
 	char *tp_doc; /* Documentation string */
 
+	traverseproc tp_traverse;
+	inquiry	     tp_clear;
+	richcmpfunc  tp_richcompare;
+
+	long tp_weakoffset;
+
 #ifdef COUNT_ALLOCS
 	/* these must be last */
 	int tp_alloc;
@@ -302,7 +308,14 @@
    { PyExtensionClassCAPI->Export(D,N,&T); }
 
 /* Convert a method list to a method chain.  */
-#define METHOD_CHAIN(DEF) { DEF, NULL }
+/* MTK -- make it pad the type structure out -- presumes only use is in
+** type structure initialization
+*/
+#ifdef COUNT_ALLOCS
+#define METHOD_CHAIN(DEF) 0,0,0,0,0,0,0,0,{ DEF, NULL }
+#else
+#define METHOD_CHAIN(DEF) 0,0,0,0,{ DEF, NULL }
+#endif
 
 /* The following macro checks whether a type is an extension class: */
 #define PyExtensionClass_Check(TYPE) \
@@ -336,7 +349,7 @@
 #define PURE_MIXIN_CLASS(NAME,DOC,METHODS) \
 static PyExtensionClass NAME ## Type = { PyObject_HEAD_INIT(NULL) \
 	0, # NAME, sizeof(PyPureMixinObject), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
-	0, 0, 0, 0, 0, 0, 0, DOC, {METHODS, NULL}, \
+	0, 0, 0, 0, 0, 0, 0, DOC, METHOD_CHAIN(METHODS), \
         EXTENSIONCLASS_BASICNEW_FLAG}
 
 /* The following macros provide limited access to extension-class