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
|
* Equivalent function prototype is
|
||||||
* GncBillTerm * gncBillTermLookup (QofBook *book, const GUID *guid);
|
* GncBillTerm * gncBillTermLookup (QofBook *book, const GUID *guid);
|
||||||
*/
|
*/
|
||||||
#define gncBillTermLookup(book,guid) \
|
static inline GncBillTerm * gncBillTermLookup (const QofBook *book, const GUID *guid)
|
||||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_BILLTERM, GncBillTerm)
|
{
|
||||||
|
QOF_BOOK_RETURN_ENTITY(book, guid,GNC_ID_BILLTERM, GncBillTerm);
|
||||||
|
}
|
||||||
|
|
||||||
GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name);
|
GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name);
|
||||||
GList * gncBillTermGetTerms (QofBook *book);
|
GList * gncBillTermGetTerms (QofBook *book);
|
||||||
|
@ -115,8 +115,10 @@ void gncCustomerRemoveJob (GncCustomer *customer, GncJob *job);
|
|||||||
* Equivalent function prototype is
|
* Equivalent function prototype is
|
||||||
* GncCustomer * gncCustomerLookup (QofBook *book, const GUID *guid);
|
* GncCustomer * gncCustomerLookup (QofBook *book, const GUID *guid);
|
||||||
*/
|
*/
|
||||||
#define gncCustomerLookup(book,guid) \
|
static inline GncCustomer * gncCustomerLookup (const QofBook *book, const GUID *guid)
|
||||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_CUSTOMER, GncCustomer)
|
{
|
||||||
|
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_CUSTOMER, GncCustomer);
|
||||||
|
}
|
||||||
|
|
||||||
const char * gncCustomerGetID (const GncCustomer *customer);
|
const char * gncCustomerGetID (const GncCustomer *customer);
|
||||||
const char * gncCustomerGetName (const GncCustomer *customer);
|
const char * gncCustomerGetName (const GncCustomer *customer);
|
||||||
|
@ -99,8 +99,10 @@ Account * gncEmployeeGetCCard (const GncEmployee *employee);
|
|||||||
* Equivalent function prototype is
|
* Equivalent function prototype is
|
||||||
* GncEmployee * gncEmployeeLookup (QofBook *book, const GUID *guid);
|
* GncEmployee * gncEmployeeLookup (QofBook *book, const GUID *guid);
|
||||||
*/
|
*/
|
||||||
#define gncEmployeeLookup(book,guid) \
|
static inline GncEmployee * gncEmployeeLookup (const QofBook *book, const GUID *guid)
|
||||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_EMPLOYEE, GncEmployee)
|
{
|
||||||
|
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_EMPLOYEE, GncEmployee);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean gncEmployeeIsDirty (const GncEmployee *employee);
|
gboolean gncEmployeeIsDirty (const GncEmployee *employee);
|
||||||
|
|
||||||
|
@ -222,8 +222,10 @@ GncInvoice * gncEntryGetBill (const GncEntry *entry);
|
|||||||
* Equivalent function prototype is
|
* Equivalent function prototype is
|
||||||
* GncEntry * gncEntryLookup (QofBook *book, const GUID *guid);
|
* GncEntry * gncEntryLookup (QofBook *book, const GUID *guid);
|
||||||
*/
|
*/
|
||||||
#define gncEntryLookup(book,guid) \
|
static inline GncEntry * gncEntryLookup (const QofBook *book, const GUID *guid)
|
||||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_ENTRY, GncEntry)
|
{
|
||||||
|
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_ENTRY, GncEntry);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean gncEntryIsOpen (const GncEntry *entry);
|
gboolean gncEntryIsOpen (const GncEntry *entry);
|
||||||
void gncEntryBeginEdit (GncEntry *entry);
|
void gncEntryBeginEdit (GncEntry *entry);
|
||||||
|
@ -185,8 +185,10 @@ GncInvoice * gncInvoiceGetInvoiceFromLot (GNCLot *lot);
|
|||||||
* Equivalent function prototype is
|
* Equivalent function prototype is
|
||||||
* GncInvoice * gncInvoiceLookup (QofBook *book, const GUID *guid);
|
* GncInvoice * gncInvoiceLookup (QofBook *book, const GUID *guid);
|
||||||
*/
|
*/
|
||||||
#define gncInvoiceLookup(book,guid) \
|
static inline GncInvoice * gncInvoiceLookup (const QofBook *book, const GUID *guid)
|
||||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_INVOICE, GncInvoice)
|
{
|
||||||
|
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_INVOICE, GncInvoice);
|
||||||
|
}
|
||||||
|
|
||||||
void gncInvoiceBeginEdit (GncInvoice *invoice);
|
void gncInvoiceBeginEdit (GncInvoice *invoice);
|
||||||
void gncInvoiceCommitEdit (GncInvoice *invoice);
|
void gncInvoiceCommitEdit (GncInvoice *invoice);
|
||||||
|
@ -90,8 +90,10 @@ gboolean gncJobGetActive (const GncJob *job);
|
|||||||
* Equivalent function prototype is
|
* Equivalent function prototype is
|
||||||
* GncJob * gncJobLookup (QofBook *book, const GUID *guid);
|
* GncJob * gncJobLookup (QofBook *book, const GUID *guid);
|
||||||
*/
|
*/
|
||||||
#define gncJobLookup(book,guid) \
|
static inline GncJob * gncJobLookup (const QofBook *book, const GUID *guid)
|
||||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_JOB, GncJob)
|
{
|
||||||
|
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_JOB, GncJob);
|
||||||
|
}
|
||||||
|
|
||||||
/* Other functions */
|
/* Other functions */
|
||||||
|
|
||||||
|
@ -101,8 +101,10 @@ gboolean gncOrderIsClosed (const GncOrder *order);
|
|||||||
* Equivalent function prototype is
|
* Equivalent function prototype is
|
||||||
* GncOrder * gncOrderLookup (QofBook *book, const GUID *guid);
|
* GncOrder * gncOrderLookup (QofBook *book, const GUID *guid);
|
||||||
*/
|
*/
|
||||||
#define gncOrderLookup(book,guid) \
|
static inline GncOrder * gncOrderLookup (const QofBook *book, const GUID *guid)
|
||||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_ORDER, GncOrder)
|
{
|
||||||
|
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_ORDER, GncOrder);
|
||||||
|
}
|
||||||
|
|
||||||
#define ORDER_ID "id"
|
#define ORDER_ID "id"
|
||||||
#define ORDER_REFERENCE "reference"
|
#define ORDER_REFERENCE "reference"
|
||||||
|
@ -144,8 +144,10 @@ void gncTaxTableCommitEdit (GncTaxTable *table);
|
|||||||
* Equivalent function prototype is
|
* Equivalent function prototype is
|
||||||
* GncTaxTable * gncTaxTableLookup (QofBook *book, const GUID *guid);
|
* GncTaxTable * gncTaxTableLookup (QofBook *book, const GUID *guid);
|
||||||
*/
|
*/
|
||||||
#define gncTaxTableLookup(book,guid) \
|
static inline GncTaxTable *gncTaxTableLookup (const QofBook* book, const GUID *guid)
|
||||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_TAXTABLE, GncTaxTable)
|
{
|
||||||
|
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_TAXTABLE, GncTaxTable);
|
||||||
|
}
|
||||||
|
|
||||||
GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name);
|
GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name);
|
||||||
|
|
||||||
|
@ -112,8 +112,10 @@ int gncVendorCompare (const GncVendor *a, const GncVendor *b);
|
|||||||
* Equivalent function prototype is
|
* Equivalent function prototype is
|
||||||
* GncVendor * gncVendorLookup (QofBook *book, const GUID *guid);
|
* GncVendor * gncVendorLookup (QofBook *book, const GUID *guid);
|
||||||
*/
|
*/
|
||||||
#define gncVendorLookup(book,guid) \
|
static inline GncVendor * gncVendorLookup (const QofBook *book, const GUID *guid)
|
||||||
QOF_BOOK_LOOKUP_ENTITY((book),(guid),GNC_ID_VENDOR, GncVendor)
|
{
|
||||||
|
QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_VENDOR, GncVendor);
|
||||||
|
}
|
||||||
|
|
||||||
#define VENDOR_ID "id"
|
#define VENDOR_ID "id"
|
||||||
#define VENDOR_NAME "name"
|
#define VENDOR_NAME "name"
|
||||||
|
@ -131,16 +131,21 @@ GType qof_book_get_type(void);
|
|||||||
* used for anchoring data.
|
* used for anchoring data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Lookup an entity by guid, returning pointer to the entity */
|
/** This macro looks up an entity by GUID and returns a pointer to the
|
||||||
#define QOF_BOOK_LOOKUP_ENTITY(book,guid,e_type,c_type) ({ \
|
* entity by ending with a "return" statement. Hence, this macro can
|
||||||
QofInstance *val = NULL; \
|
* only be used as the last statement in the definition of a function,
|
||||||
if ((guid != NULL) && (book != NULL)) { \
|
* but not somewhere inline in the code. */
|
||||||
QofCollection *col; \
|
#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); \
|
col = qof_book_get_collection (book, e_type); \
|
||||||
val = qof_collection_lookup_entity (col, guid); \
|
val = qof_collection_lookup_entity (col, guid); \
|
||||||
} \
|
} \
|
||||||
(c_type *) val; \
|
return (c_type *) val; \
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** GList of QofBook */
|
/** GList of QofBook */
|
||||||
typedef GList QofBookList;
|
typedef GList QofBookList;
|
||||||
|
Loading…
Reference in New Issue
Block a user