[Zodb-checkins] CVS: Zope3/lib/python/Persistence - cPersistenceAPI.h:1.1.2.1

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


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

Added Files:
      Tag: Zope-3x-branch
	cPersistenceAPI.h 
Log Message:
Add a separate include file that defines the C API for C extensions.


=== Added File Zope3/lib/python/Persistence/cPersistenceAPI.h ===
/* The PyPersist_C_API provides access to types and functions defined
   in the cPersistence extension module to other extension modules.
   On some (all?) platforms, it isn't possible to have static
   references to functions and objects defined in other dynamically
   loaded modules.  The PyPersist_C_API defines a collection of
   pointers to the shared functions that can be initialized when a
   module is loaded.
*/

static PyPersist_C_API_struct *PyPersist_C_API;

#define PyPersist_TYPE PyPersist_C_API->type

/* Macros for compatibility with ZODB 3 C extensions. */

#define PER_USE_OR_RETURN(O, R) \
{ \
    if (((O)->po_state == GHOST) \
	&& (PyPersist_C_API->load((PyPersistObject *)(O)) < 0)) \
	return (R); \
    else if ((O)->po_state == UPTODATE) \
	(O)->po_state = STICKY; \
}

#define PER_CHANGED(O) PyPersist_C_API->reg_trans((PyPersistObject *)(O))

#define PER_ALLOW_DEACTIVATION(O) \
{ \
    if ((O)->po_state == STICKY) \
	(O)->po_state = UPTODATE; \
}

#define PER_PREVENT_DEACTIVATION(O) \
{ \
    if ((O)->po_state == UPTODATE) \
	(O)->po_state = STICKY; \
}

/* XXX is this right? */
#define PER_DEL(O) Py_DECREF(O)

#define PER_USE(O) \
    ((((PyPersistObject *)(O))->po_state != GHOST) \
     || (PyPersist_C_API->load((PyPersistObject *)(O)) >= 0) \
     ? ((((PyPersistObject *)(O))->po_state == UPTODATE) \
	? (((PyPersistObject *)(O))->po_state = STICKY) : 1) : 0)

#define PER_ACCESSED(O) PyPersist_C_API->set_atime((PyPersistObject *)O)