From fd26e126ecf79fad60edbe87f7687e22e8d5a391 Mon Sep 17 00:00:00 2001 From: David Hampton Date: Mon, 30 Apr 2007 17:06:48 +0000 Subject: [PATCH] Remove the macro versions of qof_begin_edit and qof_commit_edit_part. The function call versions of these routines should be used instead. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16033 57a11ea4-9604-0410-9ed3-97b8803252fd --- lib/libqof/qof/qofbackend.h | 8 +- lib/libqof/qof/qofutil.h | 112 +---------------------- src/business/business-core/gncBillTerm.c | 2 +- src/business/business-core/gncEmployee.c | 2 +- src/business/business-core/gncEntry.c | 2 +- src/business/business-core/gncInvoice.c | 2 +- src/business/business-core/gncJob.c | 2 +- src/business/business-core/gncTaxTable.c | 2 +- src/business/business-core/gncVendor.c | 2 +- src/engine/gnc-pricedb.c | 4 +- 10 files changed, 11 insertions(+), 127 deletions(-) diff --git a/lib/libqof/qof/qofbackend.h b/lib/libqof/qof/qofbackend.h index 26f052177b..75292c189d 100644 --- a/lib/libqof/qof/qofbackend.h +++ b/lib/libqof/qof/qofbackend.h @@ -160,13 +160,7 @@ typedef struct QofBackend_s QofBackend; /** \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); diff --git a/lib/libqof/qof/qofutil.h b/lib/libqof/qof/qofutil.h index 4253aed5fa..5a63a76ce7 100644 --- a/lib/libqof/qof/qofutil.h +++ b/lib/libqof/qof/qofutil.h @@ -297,47 +297,12 @@ gpointer qof_util_string_cache_insert(gconstpointer key); #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 @@ gboolean qof_begin_edit(QofInstance *inst); * * @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 @@ qof_commit_edit_part2(QofInstance *inst, 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 */ /** @} */ diff --git a/src/business/business-core/gncBillTerm.c b/src/business/business-core/gncBillTerm.c index 45b1a753a2..8d33886ff4 100644 --- a/src/business/business-core/gncBillTerm.c +++ b/src/business/business-core/gncBillTerm.c @@ -421,7 +421,7 @@ void gncBillTermChanged (GncBillTerm *term) void gncBillTermBeginEdit (GncBillTerm *term) { - QOF_BEGIN_EDIT (&term->inst); + qof_begin_edit(&term->inst); } static void gncBillTermOnError (QofInstance *inst, QofBackendError errcode) diff --git a/src/business/business-core/gncEmployee.c b/src/business/business-core/gncEmployee.c index fd14e2e225..b0ff9238b2 100644 --- a/src/business/business-core/gncEmployee.c +++ b/src/business/business-core/gncEmployee.c @@ -368,7 +368,7 @@ gboolean gncEmployeeIsDirty (GncEmployee *employee) void gncEmployeeBeginEdit (GncEmployee *employee) { - QOF_BEGIN_EDIT (&employee->inst); + qof_begin_edit(&employee->inst); } static void gncEmployeeOnError (QofInstance *employee, QofBackendError errcode) diff --git a/src/business/business-core/gncEntry.c b/src/business/business-core/gncEntry.c index 1fc33992c7..386e260264 100644 --- a/src/business/business-core/gncEntry.c +++ b/src/business/business-core/gncEntry.c @@ -1188,7 +1188,7 @@ gboolean gncEntryIsOpen (GncEntry *entry) void gncEntryBeginEdit (GncEntry *entry) { - QOF_BEGIN_EDIT (&entry->inst); + qof_begin_edit(&entry->inst); } static void gncEntryOnError (QofInstance *entry, QofBackendError errcode) diff --git a/src/business/business-core/gncInvoice.c b/src/business/business-core/gncInvoice.c index ecceb260da..de952d75c8 100644 --- a/src/business/business-core/gncInvoice.c +++ b/src/business/business-core/gncInvoice.c @@ -1470,7 +1470,7 @@ gboolean gncInvoiceIsPaid (GncInvoice *invoice) void gncInvoiceBeginEdit (GncInvoice *invoice) { - QOF_BEGIN_EDIT (&invoice->inst); + qof_begin_edit(&invoice->inst); } static void gncInvoiceOnError (QofInstance *inst, QofBackendError errcode) diff --git a/src/business/business-core/gncJob.c b/src/business/business-core/gncJob.c index b29d512751..748ba14b84 100644 --- a/src/business/business-core/gncJob.c +++ b/src/business/business-core/gncJob.c @@ -281,7 +281,7 @@ qofJobSetOwner (GncJob *job, QofInstance *ent) void gncJobBeginEdit (GncJob *job) { - QOF_BEGIN_EDIT (&job->inst); + qof_begin_edit(&job->inst); } static void gncJobOnError (QofInstance *inst, QofBackendError errcode) diff --git a/src/business/business-core/gncTaxTable.c b/src/business/business-core/gncTaxTable.c index d915f12056..a3cc3588d2 100644 --- a/src/business/business-core/gncTaxTable.c +++ b/src/business/business-core/gncTaxTable.c @@ -527,7 +527,7 @@ void gncTaxTableChanged (GncTaxTable *table) void gncTaxTableBeginEdit (GncTaxTable *table) { - QOF_BEGIN_EDIT (&table->inst); + qof_begin_edit(&table->inst); } static void gncTaxTableOnError (QofInstance *inst, QofBackendError errcode) diff --git a/src/business/business-core/gncVendor.c b/src/business/business-core/gncVendor.c index 0b1618bc79..fbe9c009d0 100644 --- a/src/business/business-core/gncVendor.c +++ b/src/business/business-core/gncVendor.c @@ -445,7 +445,7 @@ void gncVendorRemoveJob (GncVendor *vendor, GncJob *job) void gncVendorBeginEdit (GncVendor *vendor) { - QOF_BEGIN_EDIT (&vendor->inst); + qof_begin_edit(&vendor->inst); } static void gncVendorOnError (QofInstance *vendor, QofBackendError errcode) diff --git a/src/engine/gnc-pricedb.c b/src/engine/gnc-pricedb.c index 96f2caeb92..e5de9a1655 100644 --- a/src/engine/gnc-pricedb.c +++ b/src/engine/gnc-pricedb.c @@ -156,7 +156,7 @@ gnc_price_clone (GNCPrice* p, QofBook *book) 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 @@ gnc_price_commit_edit (GNCPrice *p) void gnc_pricedb_begin_edit (GNCPriceDB *pdb) { - QOF_BEGIN_EDIT (&pdb->inst); + qof_begin_edit(&pdb->inst); } void