r16033 - gnucash/trunk - Remove the macro versions of qof_begin_edit and qof_commit_edit_part<x>.

David Hampton hampton at cvs.gnucash.org
Mon Apr 30 13:06:49 EDT 2007


Author: hampton
Date: 2007-04-30 13:06:48 -0400 (Mon, 30 Apr 2007)
New Revision: 16033
Trac: http://svn.gnucash.org/trac/changeset/16033

Modified:
   gnucash/trunk/lib/libqof/qof/qofbackend.h
   gnucash/trunk/lib/libqof/qof/qofutil.h
   gnucash/trunk/src/business/business-core/gncBillTerm.c
   gnucash/trunk/src/business/business-core/gncEmployee.c
   gnucash/trunk/src/business/business-core/gncEntry.c
   gnucash/trunk/src/business/business-core/gncInvoice.c
   gnucash/trunk/src/business/business-core/gncJob.c
   gnucash/trunk/src/business/business-core/gncTaxTable.c
   gnucash/trunk/src/business/business-core/gncVendor.c
   gnucash/trunk/src/engine/gnc-pricedb.c
Log:
Remove the macro versions of qof_begin_edit and qof_commit_edit_part<x>.
The function call versions of these routines should be used instead.


Modified: gnucash/trunk/lib/libqof/qof/qofbackend.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofbackend.h	2007-04-30 16:38:41 UTC (rev 16032)
+++ gnucash/trunk/lib/libqof/qof/qofbackend.h	2007-04-30 17:06:48 UTC (rev 16033)
@@ -160,13 +160,7 @@
 /** \brief DOCUMENT ME! */
 typedef void (*QofBePercentageFunc) (const char *message, double percent);
 
-/** @name Allow access to the begin routine for this backend.
-
-QOF_BEGIN_EDIT and QOF_COMMIT_EDIT_PART1 and part2 rely on 
-calling QofBackend *be->begin and be->commit. This means the
-QofBackend struct becomes part of the public API.
-These function replaces those calls to allow the macros to be
-used when QOF is built as a library. */
+/** @name Allow access to the begin routine for this backend. */
 //@{
 
 void qof_backend_run_begin(QofBackend *be, QofInstance *inst);

Modified: gnucash/trunk/lib/libqof/qof/qofutil.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofutil.h	2007-04-30 16:38:41 UTC (rev 16032)
+++ gnucash/trunk/lib/libqof/qof/qofutil.h	2007-04-30 17:06:48 UTC (rev 16033)
@@ -297,47 +297,12 @@
 
 #define QOF_CACHE_NEW(void) qof_util_string_cache_insert("")
 
-/** begin_edit helper
+/** begin_edit
  *
  * @param  inst: an instance of QofInstance
  *
  * The caller should use this macro first and then perform any other operations.
- 
- Uses newly created functions to allow the macro to be used
- when QOF is linked as a library. qofbackend-p.h is a private header.
  */
-
-#define QOF_BEGIN_EDIT(inst)                                        \
-  if (!(inst)) return;                                              \
-                                                                    \
-  (inst)->editlevel++;                                              \
-  if (1 < (inst)->editlevel) return;                                \
-                                                                    \
-  if (0 >= (inst)->editlevel)                                       \
-  {                                                                 \
-    PERR ("unbalanced call - resetting (was %d)", (inst)->editlevel); \
-    (inst)->editlevel = 1;                                          \
-  }                                                                 \
-  ENTER ("(inst=%p)", (inst));                                      \
-                                                                    \
-  /* See if there's a backend.  If there is, invoke it. */          \
-  {                                                                 \
-    QofBackend * be;                                                \
-    be = qof_book_get_backend ((inst)->book);                       \
-      if (be && qof_backend_begin_exists(be)) {                     \
-         qof_backend_run_begin(be, (inst));                         \
-    } else {                                                        \
-      /* We tried and failed to start transaction! */               \
-      (inst)->dirty = TRUE;                                         \
-    }                                                               \
-  }                                                                 \
-  LEAVE (" ");
-
-/** \brief function version of QOF_BEGIN_EDIT
-
-The macro cannot be used in a function that returns a value,
-this function can be used instead.
-*/
 gboolean qof_begin_edit(QofInstance *inst);
 
 /**
@@ -353,39 +318,6 @@
  * 
  * @param inst: an instance of QofInstance
  */
-
-#define QOF_COMMIT_EDIT_PART1(inst) {                            \
-  if (!(inst)) return;                                           \
-                                                                 \
-  (inst)->editlevel--;                                           \
-  if (0 < (inst)->editlevel) return;                             \
-                                                                 \
-  /* The pricedb suffers from delayed update...     */          \
-  /* This may be setting a bad precedent for other types, I fear. */ \
-  /* Other types probably really should handle begin like this. */ \
-  if ((0 == (inst)->editlevel) && (inst)->dirty)                   \
-  {                                                              \
-    QofBackend * be;                                             \
-    be = qof_book_get_backend ((inst)->book);                    \
-    if (be && qof_backend_commit_exists(be)) {                   \
-        qof_backend_run_commit(be, (inst));                      \
-    }                                                            \
-    (inst)->editlevel = 0;                                       \
-  }                                                              \
-  if (0 > (inst)->editlevel)                                     \
-  {                                                              \
-    PERR ("unbalanced call - resetting (was %d)", (inst)->editlevel); \
-    (inst)->editlevel = 0;                                       \
-  }                                                              \
-  ENTER ("(inst=%p) dirty=%d do-free=%d",                        \
-            (inst), (inst)->dirty, (inst)->do_free);             \
-}
-
-/** \brief function version of QOF_COMMIT_EDIT_PART1
-
-The macro cannot be used in a function that returns a value,
-this function can be used instead. Only Part1 is implemented.
-*/
 gboolean qof_commit_edit(QofInstance *inst);
 
 /**
@@ -412,48 +344,6 @@
                       void (*on_error)(QofInstance *, QofBackendError), 
                       void (*on_done)(QofInstance *), 
                       void (*on_free)(QofInstance *));
-
-/** \brief Macro version of ::qof_commit_edit_part2
-
-\note This macro changes programme flow if the instance is freed.
-*/
-#define QOF_COMMIT_EDIT_PART2(inst,on_error,on_done,on_free) {   \
-  QofBackend * be;                                               \
-                                                                 \
-  /* See if there's a backend.  If there is, invoke it. */       \
-  be = qof_book_get_backend ((inst)->book);                      \
-  if (be && qof_backend_commit_exists(be))                       \
-  {                                                              \
-    QofBackendError errcode;                                     \
-                                                                 \
-    /* clear errors */                                           \
-    do {                                                         \
-      errcode = qof_backend_get_error (be);                      \
-    } while (ERR_BACKEND_NO_ERR != errcode);                     \
-                                                                 \
-    qof_backend_run_commit(be, (inst));                          \
-    errcode = qof_backend_get_error (be);                        \
-    if (ERR_BACKEND_NO_ERR != errcode)                           \
-    {                                                            \
-      /* XXX Should perform a rollback here */                   \
-      (inst)->do_free = FALSE;                                   \
-                                                                 \
-      /* Push error back onto the stack */                       \
-      qof_backend_set_error (be, errcode);                       \
-      (on_error)((inst), errcode);                               \
-    }                                                            \
-    /* XXX the backend commit code should clear dirty!! */       \
-    (inst)->dirty = FALSE;                                       \
-  }                                                              \
-  (on_done)(inst);                                               \
-                                                                 \
-  LEAVE ("inst=%p, dirty=%d do-free=%d",                         \
-            (inst), (inst)->dirty, (inst)->do_free);             \
-  if ((inst)->do_free) {                                         \
-     (on_free)(inst);                                            \
-     return;                                                     \
-  }                                                              \
-}
     
 #endif /* QOF_UTIL_H */
 /** @} */

Modified: gnucash/trunk/src/business/business-core/gncBillTerm.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncBillTerm.c	2007-04-30 16:38:41 UTC (rev 16032)
+++ gnucash/trunk/src/business/business-core/gncBillTerm.c	2007-04-30 17:06:48 UTC (rev 16033)
@@ -421,7 +421,7 @@
 
 void gncBillTermBeginEdit (GncBillTerm *term)
 {
-  QOF_BEGIN_EDIT (&term->inst);
+  qof_begin_edit(&term->inst);
 }
 
 static void gncBillTermOnError (QofInstance *inst, QofBackendError errcode)

Modified: gnucash/trunk/src/business/business-core/gncEmployee.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncEmployee.c	2007-04-30 16:38:41 UTC (rev 16032)
+++ gnucash/trunk/src/business/business-core/gncEmployee.c	2007-04-30 17:06:48 UTC (rev 16033)
@@ -368,7 +368,7 @@
 
 void gncEmployeeBeginEdit (GncEmployee *employee)
 {
-  QOF_BEGIN_EDIT (&employee->inst);
+  qof_begin_edit(&employee->inst);
 }
 
 static void gncEmployeeOnError (QofInstance *employee, QofBackendError errcode)

Modified: gnucash/trunk/src/business/business-core/gncEntry.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncEntry.c	2007-04-30 16:38:41 UTC (rev 16032)
+++ gnucash/trunk/src/business/business-core/gncEntry.c	2007-04-30 17:06:48 UTC (rev 16033)
@@ -1188,7 +1188,7 @@
 
 void gncEntryBeginEdit (GncEntry *entry)
 {
-  QOF_BEGIN_EDIT (&entry->inst);
+  qof_begin_edit(&entry->inst);
 }
 
 static void gncEntryOnError (QofInstance *entry, QofBackendError errcode)

Modified: gnucash/trunk/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.c	2007-04-30 16:38:41 UTC (rev 16032)
+++ gnucash/trunk/src/business/business-core/gncInvoice.c	2007-04-30 17:06:48 UTC (rev 16033)
@@ -1470,7 +1470,7 @@
 
 void gncInvoiceBeginEdit (GncInvoice *invoice)
 {
-  QOF_BEGIN_EDIT (&invoice->inst);
+  qof_begin_edit(&invoice->inst);
 }
 
 static void gncInvoiceOnError (QofInstance *inst, QofBackendError errcode)

Modified: gnucash/trunk/src/business/business-core/gncJob.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncJob.c	2007-04-30 16:38:41 UTC (rev 16032)
+++ gnucash/trunk/src/business/business-core/gncJob.c	2007-04-30 17:06:48 UTC (rev 16033)
@@ -281,7 +281,7 @@
 
 void gncJobBeginEdit (GncJob *job)
 {
-  QOF_BEGIN_EDIT (&job->inst);
+  qof_begin_edit(&job->inst);
 }
 
 static void gncJobOnError (QofInstance *inst, QofBackendError errcode)

Modified: gnucash/trunk/src/business/business-core/gncTaxTable.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncTaxTable.c	2007-04-30 16:38:41 UTC (rev 16032)
+++ gnucash/trunk/src/business/business-core/gncTaxTable.c	2007-04-30 17:06:48 UTC (rev 16033)
@@ -527,7 +527,7 @@
 
 void gncTaxTableBeginEdit (GncTaxTable *table)
 {
-  QOF_BEGIN_EDIT (&table->inst);
+  qof_begin_edit(&table->inst);
 }
 
 static void gncTaxTableOnError (QofInstance *inst, QofBackendError errcode)

Modified: gnucash/trunk/src/business/business-core/gncVendor.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncVendor.c	2007-04-30 16:38:41 UTC (rev 16032)
+++ gnucash/trunk/src/business/business-core/gncVendor.c	2007-04-30 17:06:48 UTC (rev 16033)
@@ -445,7 +445,7 @@
 
 void gncVendorBeginEdit (GncVendor *vendor)
 {
-  QOF_BEGIN_EDIT (&vendor->inst);
+  qof_begin_edit(&vendor->inst);
 }
 
 static void gncVendorOnError (QofInstance *vendor, QofBackendError errcode)

Modified: gnucash/trunk/src/engine/gnc-pricedb.c
===================================================================
--- gnucash/trunk/src/engine/gnc-pricedb.c	2007-04-30 16:38:41 UTC (rev 16032)
+++ gnucash/trunk/src/engine/gnc-pricedb.c	2007-04-30 17:06:48 UTC (rev 16033)
@@ -156,7 +156,7 @@
 void
 gnc_price_begin_edit (GNCPrice *p)
 {
-  QOF_BEGIN_EDIT (&p->inst);
+  qof_begin_edit(&p->inst);
 }
 
 static void commit_err (QofInstance *inst, QofBackendError errcode)
@@ -178,7 +178,7 @@
 void
 gnc_pricedb_begin_edit (GNCPriceDB *pdb)
 {
-  QOF_BEGIN_EDIT (&pdb->inst);
+  qof_begin_edit(&pdb->inst);
 }
 
 void



More information about the gnucash-changes mailing list