mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
MSVC compatiblity: Replace QOF_BOOK_LOOKUP_ENTITY macro by a RETURN_ENTITY macro and add inline functions for lookup.
MSVC doesn't accept the syntax with an inlined block, x = ({ foo; bar; value;}). Hence, this is being replaced by actual function definitions, and the body of those functions is defined by the new macro. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18851 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3b44812c29
commit
5396817936
@ -119,8 +119,10 @@ void gncBillTermSetCutoff (GncBillTerm *term, gint cutoff);
|
||||
* Equivalent function prototype is
|
||||
* GncBillTerm * gncBillTermLookup (QofBook *book, const GUID *guid);
|
||||
*/
|
||||
#define gncBillTermLookup(book,guid) \
|
||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_BILLTERM, GncBillTerm)
|
||||
static inline GncBillTerm * gncBillTermLookup (const QofBook *book, const GUID *guid)
|
||||
{
|
||||
QOF_BOOK_RETURN_ENTITY(book, guid,GNC_ID_BILLTERM, GncBillTerm);
|
||||
}
|
||||
|
||||
GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name);
|
||||
GList * gncBillTermGetTerms (QofBook *book);
|
||||
|
@ -115,8 +115,10 @@ void gncCustomerRemoveJob (GncCustomer *customer, GncJob *job);
|
||||
* Equivalent function prototype is
|
||||
* GncCustomer * gncCustomerLookup (QofBook *book, const GUID *guid);
|
||||
*/
|
||||
#define gncCustomerLookup(book,guid) \
|
||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_CUSTOMER, GncCustomer)
|
||||
static inline GncCustomer * gncCustomerLookup (const QofBook *book, const GUID *guid)
|
||||
{
|
||||
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_CUSTOMER, GncCustomer);
|
||||
}
|
||||
|
||||
const char * gncCustomerGetID (const GncCustomer *customer);
|
||||
const char * gncCustomerGetName (const GncCustomer *customer);
|
||||
|
@ -99,8 +99,10 @@ Account * gncEmployeeGetCCard (const GncEmployee *employee);
|
||||
* Equivalent function prototype is
|
||||
* GncEmployee * gncEmployeeLookup (QofBook *book, const GUID *guid);
|
||||
*/
|
||||
#define gncEmployeeLookup(book,guid) \
|
||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_EMPLOYEE, GncEmployee)
|
||||
static inline GncEmployee * gncEmployeeLookup (const QofBook *book, const GUID *guid)
|
||||
{
|
||||
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_EMPLOYEE, GncEmployee);
|
||||
}
|
||||
|
||||
gboolean gncEmployeeIsDirty (const GncEmployee *employee);
|
||||
|
||||
|
@ -222,8 +222,10 @@ GncInvoice * gncEntryGetBill (const GncEntry *entry);
|
||||
* Equivalent function prototype is
|
||||
* GncEntry * gncEntryLookup (QofBook *book, const GUID *guid);
|
||||
*/
|
||||
#define gncEntryLookup(book,guid) \
|
||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_ENTRY, GncEntry)
|
||||
static inline GncEntry * gncEntryLookup (const QofBook *book, const GUID *guid)
|
||||
{
|
||||
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_ENTRY, GncEntry);
|
||||
}
|
||||
|
||||
gboolean gncEntryIsOpen (const GncEntry *entry);
|
||||
void gncEntryBeginEdit (GncEntry *entry);
|
||||
|
@ -185,8 +185,10 @@ GncInvoice * gncInvoiceGetInvoiceFromLot (GNCLot *lot);
|
||||
* Equivalent function prototype is
|
||||
* GncInvoice * gncInvoiceLookup (QofBook *book, const GUID *guid);
|
||||
*/
|
||||
#define gncInvoiceLookup(book,guid) \
|
||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_INVOICE, GncInvoice)
|
||||
static inline GncInvoice * gncInvoiceLookup (const QofBook *book, const GUID *guid)
|
||||
{
|
||||
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_INVOICE, GncInvoice);
|
||||
}
|
||||
|
||||
void gncInvoiceBeginEdit (GncInvoice *invoice);
|
||||
void gncInvoiceCommitEdit (GncInvoice *invoice);
|
||||
|
@ -90,8 +90,10 @@ gboolean gncJobGetActive (const GncJob *job);
|
||||
* Equivalent function prototype is
|
||||
* GncJob * gncJobLookup (QofBook *book, const GUID *guid);
|
||||
*/
|
||||
#define gncJobLookup(book,guid) \
|
||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_JOB, GncJob)
|
||||
static inline GncJob * gncJobLookup (const QofBook *book, const GUID *guid)
|
||||
{
|
||||
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_JOB, GncJob);
|
||||
}
|
||||
|
||||
/* Other functions */
|
||||
|
||||
|
@ -101,8 +101,10 @@ gboolean gncOrderIsClosed (const GncOrder *order);
|
||||
* Equivalent function prototype is
|
||||
* GncOrder * gncOrderLookup (QofBook *book, const GUID *guid);
|
||||
*/
|
||||
#define gncOrderLookup(book,guid) \
|
||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_ORDER, GncOrder)
|
||||
static inline GncOrder * gncOrderLookup (const QofBook *book, const GUID *guid)
|
||||
{
|
||||
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_ORDER, GncOrder);
|
||||
}
|
||||
|
||||
#define ORDER_ID "id"
|
||||
#define ORDER_REFERENCE "reference"
|
||||
|
@ -144,8 +144,10 @@ void gncTaxTableCommitEdit (GncTaxTable *table);
|
||||
* Equivalent function prototype is
|
||||
* GncTaxTable * gncTaxTableLookup (QofBook *book, const GUID *guid);
|
||||
*/
|
||||
#define gncTaxTableLookup(book,guid) \
|
||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_TAXTABLE, GncTaxTable)
|
||||
static inline GncTaxTable *gncTaxTableLookup (const QofBook* book, const GUID *guid)
|
||||
{
|
||||
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_TAXTABLE, GncTaxTable);
|
||||
}
|
||||
|
||||
GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name);
|
||||
|
||||
|
@ -112,8 +112,10 @@ int gncVendorCompare (const GncVendor *a, const GncVendor *b);
|
||||
* Equivalent function prototype is
|
||||
* GncVendor * gncVendorLookup (QofBook *book, const GUID *guid);
|
||||
*/
|
||||
#define gncVendorLookup(book,guid) \
|
||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_VENDOR, GncVendor)
|
||||
static inline GncVendor * gncVendorLookup (const QofBook *book, const GUID *guid)
|
||||
{
|
||||
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_VENDOR, GncVendor);
|
||||
}
|
||||
|
||||
#define VENDOR_ID "id"
|
||||
#define VENDOR_NAME "name"
|
||||
|
@ -131,16 +131,21 @@ GType qof_book_get_type(void);
|
||||
* used for anchoring data.
|
||||
*/
|
||||
|
||||
/** Lookup an entity by guid, returning pointer to the entity */
|
||||
#define QOF_BOOK_LOOKUP_ENTITY(book,guid,e_type,c_type) ({ \
|
||||
QofInstance *val = NULL; \
|
||||
if ((guid != NULL) && (book != NULL)) { \
|
||||
QofCollection *col; \
|
||||
/** This macro looks up an entity by GUID and returns a pointer to the
|
||||
* entity by ending with a "return" statement. Hence, this macro can
|
||||
* only be used as the last statement in the definition of a function,
|
||||
* but not somewhere inline in the code. */
|
||||
#define QOF_BOOK_RETURN_ENTITY(book,guid,e_type,c_type) { \
|
||||
QofInstance *val = NULL; \
|
||||
if ((guid != NULL) && (book != NULL)) { \
|
||||
const QofCollection *col; \
|
||||
col = qof_book_get_collection (book, e_type); \
|
||||
val = qof_collection_lookup_entity (col, guid); \
|
||||
} \
|
||||
(c_type *) val; \
|
||||
})
|
||||
return (c_type *) val; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** GList of QofBook */
|
||||
typedef GList QofBookList;
|
||||
|
Loading…
Reference in New Issue
Block a user