r19890 - gnucash/trunk/src - Bug #635469: Add a (typemap for a) QofQueryParamList typedef.

Christian Stimming cstim at code.gnucash.org
Sat Nov 27 16:57:01 EST 2010


Author: cstim
Date: 2010-11-27 16:57:00 -0500 (Sat, 27 Nov 2010)
New Revision: 19890
Trac: http://svn.gnucash.org/trac/changeset/19890

Modified:
   gnucash/trunk/src/engine/engine.i
   gnucash/trunk/src/libqof/qof/qofquery-p.h
   gnucash/trunk/src/libqof/qof/qofquery.c
   gnucash/trunk/src/libqof/qof/qofquery.h
   gnucash/trunk/src/libqof/qof/qofquerycore.c
   gnucash/trunk/src/libqof/qof/qofquerycore.h
Log:
Bug #635469: Add a (typemap for a) QofQueryParamList typedef.

Patch by Matthijs Kooijman:

This is a typedef for a GSList, that is used to identify the path from
an object to one of its parameters in search queries and sorting.

This typedef replaces GSList everywhere where it's applicable. This
relieves the need to special case a few functions in the swig bindings
and makes the bindings for a bunch of other functions work as well.

Note this is (still) only an in typemap, since no useful functions that
return a QofQueryParamList are exposed in the bindings right now anyway.

Modified: gnucash/trunk/src/engine/engine.i
===================================================================
--- gnucash/trunk/src/engine/engine.i	2010-11-27 21:54:29 UTC (rev 19889)
+++ gnucash/trunk/src/engine/engine.i	2010-11-27 21:57:00 UTC (rev 19890)
@@ -99,21 +99,14 @@
   return qof_query_create_for(GNC_ID_SPLIT);
 }
 }
-%typemap(in) GSList * "$1 = gnc_query_scm2path($input);"
 
-void qof_query_add_guid_match (QofQuery *q, GSList *param_list,
-                           const GncGUID *guid, QofQueryOp op);
-void qof_query_set_sort_order (QofQuery *q, GSList *params1,
-                           GSList *params2, GSList *params3);
-
-%clear GSList *;
 SplitList * qof_query_run (QofQuery *q);
 SplitList * qof_query_last_run (QofQuery *q);
 SplitList * qof_query_run_subquery (QofQuery *q, const QofQuery *q);
 
+%typemap(in) QofQueryParamList * "$1 = gnc_query_scm2path($input);"
+
 %include <Query.h>
-%ignore qof_query_add_guid_match;
-%ignore qof_query_set_sort_order;
 %ignore qof_query_run;
 %ignore qof_query_last_run;
 %ignore qof_query_run_subquery;

Modified: gnucash/trunk/src/libqof/qof/qofquery-p.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qofquery-p.h	2010-11-27 21:54:29 UTC (rev 19889)
+++ gnucash/trunk/src/libqof/qof/qofquery-p.h	2010-11-27 21:57:00 UTC (rev 19890)
@@ -47,7 +47,7 @@
 GList * qof_query_get_terms (const QofQuery *q);
 
 /*@ dependent @*/
-GSList * qof_query_term_get_param_path (const QofQueryTerm *queryterm);
+QofQueryParamList * qof_query_term_get_param_path (const QofQueryTerm *queryterm);
 /*@ dependent @*/
 QofQueryPredData *qof_query_term_get_pred_data (const QofQueryTerm *queryterm);
 gboolean qof_query_term_is_inverted (const QofQueryTerm *queryterm);
@@ -62,7 +62,7 @@
                           QofQuerySort **secondary, QofQuerySort **tertiary);
 
 /*@ dependent @*/
-GSList * qof_query_sort_get_param_path (const QofQuerySort *querysort);
+QofQueryParamList * qof_query_sort_get_param_path (const QofQuerySort *querysort);
 gint qof_query_sort_get_sort_options (const QofQuerySort *querysort);
 gboolean qof_query_sort_get_increasing (const QofQuerySort *querysort);
 

Modified: gnucash/trunk/src/libqof/qof/qofquery.c
===================================================================
--- gnucash/trunk/src/libqof/qof/qofquery.c	2010-11-27 21:54:29 UTC (rev 19889)
+++ gnucash/trunk/src/libqof/qof/qofquery.c	2010-11-27 21:57:00 UTC (rev 19890)
@@ -40,7 +40,7 @@
 
 struct _QofQueryTerm
 {
-    GSList *                param_list;
+    QofQueryParamList *     param_list;
     QofQueryPredData        *pdata;
     gboolean                invert;
 
@@ -55,7 +55,7 @@
 
 struct _QofQuerySort
 {
-    GSList *            param_list;
+    QofQueryParamList * param_list;
     gint                options;
     gboolean            increasing;
 
@@ -419,7 +419,7 @@
  * returns NULL if the first parameter is bad (and final is unchanged).
  */
 static GSList *
-compile_params (GSList *param_list, QofIdType start_obj,
+compile_params (QofQueryParamList *param_list, QofIdType start_obj,
                 QofParam const **final)
 {
     const QofParam *objDef = NULL;
@@ -569,7 +569,7 @@
     return;
 }
 
-static int param_list_cmp (const GSList *l1, const GSList *l2)
+static int param_list_cmp (const QofQueryParamList *l1, const QofQueryParamList *l2)
 {
     while (1)
     {
@@ -626,10 +626,10 @@
 /********************************************************************/
 /* PUBLISHED API FUNCTIONS */
 
-GSList *
+QofQueryParamList *
 qof_query_build_param_list (char const *param, ...)
 {
-    GSList *param_list = NULL;
+    QofQueryParamList *param_list = NULL;
     char const *this_param;
     va_list ap;
 
@@ -646,7 +646,7 @@
     return g_slist_reverse (param_list);
 }
 
-void qof_query_add_term (QofQuery *q, GSList *param_list,
+void qof_query_add_term (QofQuery *q, QofQueryParamList *param_list,
                          QofQueryPredData *pred_data, QofQueryOp op)
 {
     QofQueryTerm *qt;
@@ -670,7 +670,7 @@
     qof_query_destroy (qr);
 }
 
-void qof_query_purge_terms (QofQuery *q, GSList *param_list)
+void qof_query_purge_terms (QofQuery *q, QofQueryParamList *param_list)
 {
     QofQueryTerm *qt;
     GList *or, *and;
@@ -927,7 +927,7 @@
     return n;
 }
 
-gboolean qof_query_has_term_type (QofQuery *q, GSList *term_param)
+gboolean qof_query_has_term_type (QofQuery *q, QofQueryParamList *term_param)
 {
     GList *or;
     GList *and;
@@ -948,7 +948,7 @@
     return FALSE;
 }
 
-GSList * qof_query_get_term_type (QofQuery *q, GSList *term_param)
+GSList * qof_query_get_term_type (QofQuery *q, QofQueryParamList *term_param)
 {
     GList *or;
     GList *and;
@@ -1210,7 +1210,7 @@
 
 void
 qof_query_set_sort_order (QofQuery *q,
-                          GSList *params1, GSList *params2, GSList *params3)
+                          QofQueryParamList *params1, QofQueryParamList *params2, QofQueryParamList *params3)
 {
     if (!q) return;
     if (q->primary_sort.param_list)
@@ -1255,7 +1255,7 @@
     q->max_results = n;
 }
 
-void qof_query_add_guid_list_match (QofQuery *q, GSList *param_list,
+void qof_query_add_guid_list_match (QofQuery *q, QofQueryParamList *param_list,
                                     GList *guid_list, QofGuidMatch options,
                                     QofQueryOp op)
 {
@@ -1270,7 +1270,7 @@
     qof_query_add_term (q, param_list, pdata, op);
 }
 
-void qof_query_add_guid_match (QofQuery *q, GSList *param_list,
+void qof_query_add_guid_match (QofQuery *q, QofQueryParamList *param_list,
                                const GncGUID *guid, QofQueryOp op)
 {
     GList *g = NULL;
@@ -1288,7 +1288,7 @@
 
 void qof_query_set_book (QofQuery *q, QofBook *book)
 {
-    GSList *slist = NULL;
+    QofQueryParamList *slist = NULL;
     if (!q || !book) return;
 
     /* Make sure this book is only in the list once */
@@ -1307,7 +1307,7 @@
     return q->books;
 }
 
-void qof_query_add_boolean_match (QofQuery *q, GSList *param_list, gboolean value,
+void qof_query_add_boolean_match (QofQuery *q, QofQueryParamList *param_list, gboolean value,
                                   QofQueryOp op)
 {
     QofQueryPredData *pdata;
@@ -1352,7 +1352,7 @@
     return q->terms;
 }
 
-GSList * qof_query_term_get_param_path (const QofQueryTerm *qt)
+QofQueryParamList * qof_query_term_get_param_path (const QofQueryTerm *qt)
 {
     if (!qt)
         return NULL;
@@ -1386,7 +1386,7 @@
         *tertiary = &(q->tertiary_sort);
 }
 
-GSList * qof_query_sort_get_param_path (const QofQuerySort *qs)
+QofQueryParamList * qof_query_sort_get_param_path (const QofQuerySort *qs)
 {
     if (!qs)
         return NULL;
@@ -1484,7 +1484,7 @@
 static gchar *qof_query_printGuidMatch (QofGuidMatch g);
 static gchar *qof_query_printCharMatch (QofCharMatch c);
 static GList *qof_query_printPredData (QofQueryPredData *pd, GList *lst);
-static GString *qof_query_printParamPath (GSList * parmList);
+static GString *qof_query_printParamPath (QofQueryParamList * parmList);
 static void qof_query_printValueForParam (QofQueryPredData *pd, GString * gs);
 static void qof_query_printOutput (GList * output);
 
@@ -1606,7 +1606,7 @@
 static GList *
 qof_query_printSorts (QofQuerySort *s[], const gint numSorts, GList * output)
 {
-    GSList *gsl, *n = NULL;
+    QofQueryParamList *gsl, *n = NULL;
     gint curSort;
     GString *gs = g_string_new ("Sort Parameters:   ");
 
@@ -1649,7 +1649,7 @@
     const char *prefix = "AND Terms:";
     QofQueryTerm *qt;
     QofQueryPredData *pd;
-    GSList *path;
+    QofQueryParamList *path;
     GList *lst;
     gboolean invert;
 
@@ -1675,9 +1675,9 @@
         Process the parameter types of the predicate data
 */
 static GString *
-qof_query_printParamPath (GSList * parmList)
+qof_query_printParamPath (QofQueryParamList * parmList)
 {
-    GSList *list = NULL;
+    QofQueryParamList *list = NULL;
     GString *gs = g_string_new ("Param List: ");
     g_string_append (gs, " ");
     for (list = parmList; list; list = list->next)

Modified: gnucash/trunk/src/libqof/qof/qofquery.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qofquery.h	2010-11-27 21:54:29 UTC (rev 19889)
+++ gnucash/trunk/src/libqof/qof/qofquery.h	2010-11-27 21:57:00 UTC (rev 19890)
@@ -126,7 +126,7 @@
 /** \name Low-Level API Functions */
 // @{
 
-GSList * qof_query_build_param_list (char const *param, ...);
+QofQueryParamList * qof_query_build_param_list (char const *param, ...);
 
 /** Create a new query.
  *  Before running the query, a 'search-for' type must be set
@@ -184,14 +184,14 @@
  *   obja->thingy == objb->stuff
  */
 
-void qof_query_add_term (QofQuery *query, GSList *param_list,
+void qof_query_add_term (QofQuery *query, QofQueryParamList *param_list,
                          QofQueryPredData *pred_data, QofQueryOp op);
 
 /** DOCUMENT ME !! */
-void qof_query_add_guid_match (QofQuery *q, GSList *param_list,
+void qof_query_add_guid_match (QofQuery *q, QofQueryParamList *param_list,
                                const GncGUID *guid, QofQueryOp op);
 /** DOCUMENT ME !! */
-void qof_query_add_guid_list_match (QofQuery *q, GSList *param_list,
+void qof_query_add_guid_list_match (QofQuery *q, QofQueryParamList *param_list,
                                     GList *guid_list, QofGuidMatch options,
                                     QofQueryOp op);
 
@@ -200,7 +200,7 @@
  * create handy-dandy sugar routines for the other predicate types
  * as well. */
 void qof_query_add_boolean_match (QofQuery *q,
-                                  GSList *param_list,
+                                  QofQueryParamList *param_list,
                                   gboolean value,
                                   QofQueryOp op);
 
@@ -243,7 +243,7 @@
  * XXX ??? Huh? remove anything of that predicate type, or just
  * the particular predicate ?
  */
-void qof_query_purge_terms (QofQuery *q, GSList *param_list);
+void qof_query_purge_terms (QofQuery *q, QofQueryParamList *param_list);
 
 /** Return boolean FALSE if there are no terms in the query
  *  Can be used as a predicate to see if the query has been
@@ -256,8 +256,8 @@
 int qof_query_num_terms (QofQuery *q);
 
 /** DOCUMENT ME !! */
-gboolean qof_query_has_term_type (QofQuery *q, GSList *term_param);
-GSList * qof_query_get_term_type (QofQuery *q, GSList *term_param);
+gboolean qof_query_has_term_type (QofQuery *q, QofQueryParamList *term_param);
+GSList * qof_query_get_term_type (QofQuery *q, QofQueryParamList *term_param);
 
 /** Make a copy of the indicated query */
 QofQuery * qof_query_copy (QofQuery *q);
@@ -321,9 +321,9 @@
  * new lists are set).
  */
 void qof_query_set_sort_order (QofQuery *q,
-                               GSList *primary_sort_params,
-                               GSList *secondary_sort_params,
-                               GSList *tertiary_sort_params);
+                               QofQueryParamList *primary_sort_params,
+                               QofQueryParamList *secondary_sort_params,
+                               QofQueryParamList *tertiary_sort_params);
 
 void qof_query_set_sort_options (QofQuery *q, gint prim_op, gint sec_op,
                                  gint tert_op);

Modified: gnucash/trunk/src/libqof/qof/qofquerycore.c
===================================================================
--- gnucash/trunk/src/libqof/qof/qofquerycore.c	2010-11-27 21:54:29 UTC (rev 19889)
+++ gnucash/trunk/src/libqof/qof/qofquerycore.c	2010-11-27 21:57:00 UTC (rev 19890)
@@ -1244,7 +1244,7 @@
 kvp_free_pdata (QofQueryPredData *pd)
 {
     query_kvp_t pdata = (query_kvp_t)pd;
-    GSList *node;
+    QofQueryParamList *node;
 
     VERIFY_PDATA (query_kvp_type);
     kvp_value_delete (pdata->value);
@@ -1270,7 +1270,7 @@
 {
     const query_kvp_t pd1 = (const query_kvp_t) p1;
     const query_kvp_t pd2 = (const query_kvp_t) p2;
-    GSList *n1, *n2;
+    QofQueryParamList *n1, *n2;
 
     n1 = pd1->path;
     n2 = pd2->path;
@@ -1289,10 +1289,10 @@
 
 QofQueryPredData *
 qof_query_kvp_predicate (QofQueryCompare how,
-                         GSList *path, const KvpValue *value)
+                         QofQueryParamList *path, const KvpValue *value)
 {
     query_kvp_t pdata;
-    GSList *node;
+    QofQueryParamList *node;
 
     g_return_val_if_fail (path && value, NULL);
 
@@ -1312,7 +1312,7 @@
                               const char *path, const KvpValue *value)
 {
     QofQueryPredData *pd;
-    GSList *spath = NULL;
+    QofQueryParamList *spath = NULL;
     char *str, *p;
 
     if (!path) return NULL;

Modified: gnucash/trunk/src/libqof/qof/qofquerycore.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qofquerycore.h	2010-11-27 21:54:29 UTC (rev 19889)
+++ gnucash/trunk/src/libqof/qof/qofquerycore.h	2010-11-27 21:57:00 UTC (rev 19890)
@@ -140,6 +140,9 @@
     QofQueryCompare       how;
 };
 
+/** A list of parameters (::QofIdType) used to describe a parameter to
+ * use in a predicate or when sorting */
+typedef GSList QofQueryParamList;
 
 /** @name Core Data Type Predicates
     @{ */
@@ -172,7 +175,7 @@
  *  sense, the 'path' is handled as if it were a paramter.
  */
 QofQueryPredData *qof_query_kvp_predicate (QofQueryCompare how,
-        GSList *path,
+        QofQueryParamList *path,
         const KvpValue *value);
 
 /** Same predicate as above, except that 'path' is assumed to be



More information about the gnucash-changes mailing list