[Zodb-checkins] CVS: Zope3/lib/python/Persistence - cPersistence.h:1.1.2.4

Jeremy Hylton jeremy@zope.com
Wed, 20 Feb 2002 18:24:43 -0500


Update of /cvs-repository/Zope3/lib/python/Persistence
In directory cvs.zope.org:/tmp/cvs-serv14282/lib/python/Persistence

Modified Files:
      Tag: Zope-3x-branch
	cPersistence.h 
Log Message:
Many changes -- enough for Persistence tests to pass.

Split PyPersist_HEAD into two parts, PyPersist_HEAD and
PyPersist_INSTANCE_HEAD.  The former does not provide an __dict__,
while the latter does.

Make po_atime an int rather than a time_t.

Define PyPersist_C_API_struct the exposes the PyPersist_Type and three
helper functions to C extensions.


=== Zope3/lib/python/Persistence/cPersistence.h 1.1.2.3 => 1.1.2.4 ===
 
+/* Conceptually an enum is appropriate, but we may want to pack the
+   enum into a very small number of bits -- say 2 or 3.  When we get
+   to this level of optimization, we'll probably need a collection of
+   #define constants.
+*/
+
 enum PyPersist_State { UPTODATE, CHANGED, STICKY, GHOST };
 
+/* The PyPersist_HEAD defines the minimal slots needed by a persistent
+   object.  It exists to support types like BTrees that are defined in
+   C extension modules.
+
+   PyPersistObject is the C extension type used as a mixin for
+   persistent objects defined in Python.  It extends the slots defined
+   by PyPersist_HEAD with a po_dict used to provide __dict__.  The
+   dict is needed for Python instances, but is unnecessary for objects
+   like BTrees.
+*/
+
 #define PyPersist_HEAD \
     PyObject_HEAD \
-    PyObject *po_dict; \
     PyObject *po_dm; \
     /* XXX oid and serial could be hard-coded as 8-byte strings */ \
     PyObject *po_oid; \
     PyObject *po_serial; \
-    time_t po_atime; \
+    int po_atime; \
     enum PyPersist_State po_state;
 
+#define PyPersist_INSTANCE_HEAD \
+    PyPersist_HEAD \
+    PyObject *po_dict; 
+
 typedef struct {
-    PyPersist_HEAD
+    PyPersist_INSTANCE_HEAD
 } PyPersistObject;
+
+/* XXX need to make these macros in cPersistenceAPI.h */
+extern PyObject *PyPersist_Load(PyPersistObject *);
+extern PyObject *PyPersist_RegisterDataManager(PyPersistObject *);
+extern int PyPersist_RegisterTransaction(PyPersistObject *);
+extern void PyPersist_SetATime(PyPersistObject *);
+
+/* A struct to encapsulation the PyPersist C API for use by other
+   dynamically load extensions.
+*/
+
+typedef struct {
+    PyTypeObject *type;
+    PyObject *(*load)(PyPersistObject *);
+    int (*reg_trans)(PyPersistObject *);
+    void (*set_atime)(PyPersistObject *);
+} PyPersist_C_API_struct;