r20621 - gnucash/trunk/src - Refactor gncOwnerCreate/Destroy into gncOwnerNew/Free to avoid confusion with similar gnc<ownertype>Create/Destroy functions, like gncVendorCreate, gncCustomerDestroy and so on. The type specific functions add or delete the owner from the book, while the generic one only allocated memory or freed memory to hold a generic owner. Changing the name makes it clear the generic and specific functions are not related. Note: this change may require a clean rebuild. I'm not sure if swig picks this up automatically.

Geert Janssens gjanssens at code.gnucash.org
Wed May 11 17:51:18 EDT 2011


Author: gjanssens
Date: 2011-05-11 17:51:17 -0400 (Wed, 11 May 2011)
New Revision: 20621
Trac: http://svn.gnucash.org/trac/changeset/20621

Modified:
   gnucash/trunk/src/business/business-core/business-core.scm
   gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
   gnucash/trunk/src/business/business-utils/business-options.scm
   gnucash/trunk/src/engine/gncBusiness.c
   gnucash/trunk/src/engine/gncOwner.c
   gnucash/trunk/src/engine/gncOwner.h
   gnucash/trunk/src/gnome-utils/gnc-tree-view-owner.c
   gnucash/trunk/src/optional/python-bindings/gnucash_core.i
   gnucash/trunk/src/plugins/bi_import/bi_import.c
   gnucash/trunk/src/report/business-reports/aging.scm
   gnucash/trunk/src/report/business-reports/owner-report.scm
Log:
Refactor gncOwnerCreate/Destroy into gncOwnerNew/Free to avoid confusion with similar gnc<ownertype>Create/Destroy functions, like gncVendorCreate, gncCustomerDestroy and so on. The type specific functions add or delete the owner from the book, while the generic one only allocated memory or freed memory to hold a generic owner. Changing the name makes it clear the generic and specific functions are not related. Note: this change may require a clean rebuild. I'm not sure if swig picks this up automatically.

Modified: gnucash/trunk/src/business/business-core/business-core.scm
===================================================================
--- gnucash/trunk/src/business/business-core/business-core.scm	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/business/business-core/business-core.scm	2011-05-11 21:51:17 UTC (rev 20621)
@@ -92,7 +92,7 @@
 (define (gnc:owner-from-split split result-owner)
   (let* ((trans (xaccSplitGetParent split))
 	 (invoice (gncInvoiceGetInvoiceFromTxn trans))
-	 (temp-owner (gncOwnerCreate))
+	 (temp-owner (gncOwnerNew))
 	 (owner '()))
 
     (if (not (null? invoice))
@@ -117,10 +117,10 @@
     (if (not (null? owner))
 	(begin
 	  (gncOwnerCopy (gncOwnerGetEndOwner owner) result-owner)
-	  (gncOwnerDestroy temp-owner)
+	  (gncOwnerFree temp-owner)
 	  result-owner)
 	(begin
-	  (gncOwnerDestroy temp-owner)
+	  (gncOwnerFree temp-owner)
 	  '()))))
 
 

Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c	2011-05-11 21:51:17 UTC (rev 20621)
@@ -398,13 +398,13 @@
     GncPluginBusinessPrivate *priv;
 
     priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
-    priv->last_customer = gncOwnerCreate ();
+    priv->last_customer = gncOwnerNew ();
     gncOwnerInitCustomer (priv->last_customer, NULL);
 
-    priv->last_vendor = gncOwnerCreate ();
+    priv->last_vendor = gncOwnerNew ();
     gncOwnerInitVendor (priv->last_vendor, NULL);
 
-    priv->last_employee = gncOwnerCreate ();
+    priv->last_employee = gncOwnerNew ();
     gncOwnerInitEmployee (priv->last_employee, NULL);
 }
 
@@ -804,7 +804,7 @@
     GncCustomer *customer	= gncCustomerCreate(book);
     GncAddress *address	= gncCustomerGetAddr(customer);
     GncInvoice *invoice	= gncInvoiceCreate(book);
-    GncOwner *owner		= gncOwnerCreate();
+    GncOwner *owner		= gncOwnerNew();
     GncJob *job		= gncJobCreate(book);
     Account *root		= gnc_book_get_root_account(book);
     Account *inc_acct	= xaccMallocAccount(book);

Modified: gnucash/trunk/src/business/business-utils/business-options.scm
===================================================================
--- gnucash/trunk/src/business/business-utils/business-options.scm	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/business/business-utils/business-options.scm	2011-05-11 21:51:17 UTC (rev 20621)
@@ -279,7 +279,7 @@
 	 value-validator
 	 owner-type)
 
-  (let ((option-value (gncOwnerCreate)))
+  (let ((option-value (gncOwnerNew)))
 
     (define (convert-to-pair item)
       (if (pair? item)

Modified: gnucash/trunk/src/engine/gncBusiness.c
===================================================================
--- gnucash/trunk/src/engine/gncBusiness.c	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/engine/gncBusiness.c	2011-05-11 21:51:17 UTC (rev 20621)
@@ -65,7 +65,7 @@
     struct _get_list_userdata* data = user_data;
     if (!data->is_active_accessor_func || data->is_active_accessor_func(inst, NULL))
     {
-        GncOwner *owner = gncOwnerCreate();
+        GncOwner *owner = gncOwnerNew();
         qofOwnerSetEntity(owner, inst);
         data->result = g_list_prepend(data->result, owner);
     }

Modified: gnucash/trunk/src/engine/gncOwner.c
===================================================================
--- gnucash/trunk/src/engine/gncOwner.c	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/engine/gncOwner.c	2011-05-11 21:51:17 UTC (rev 20621)
@@ -46,7 +46,7 @@
 #define GNC_OWNER_TYPE  "owner-type"
 #define GNC_OWNER_GUID  "owner-guid"
 
-GncOwner * gncOwnerCreate (void)
+GncOwner * gncOwnerNew (void)
 {
     GncOwner *o;
 
@@ -55,7 +55,7 @@
     return o;
 }
 
-void gncOwnerDestroy (GncOwner *owner)
+void gncOwnerFree (GncOwner *owner)
 {
     if (!owner) return;
     g_free (owner);

Modified: gnucash/trunk/src/engine/gncOwner.h
===================================================================
--- gnucash/trunk/src/engine/gncOwner.h	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/engine/gncOwner.h	2011-05-11 21:51:17 UTC (rev 20621)
@@ -176,8 +176,8 @@
  * Normal C code has no need to ever use these two functions, and rather
  * can just use a GncOwner directly and just pass around a pointer to it.
  */
-GncOwner * gncOwnerCreate (void);
-void gncOwnerDestroy (GncOwner *owner);
+GncOwner * gncOwnerNew (void);
+void gncOwnerFree (GncOwner *owner);
 
 #endif /* GNC_OWNER_H_ */
 /** @} */

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-owner.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-owner.c	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-owner.c	2011-05-11 21:51:17 UTC (rev 20621)
@@ -1561,7 +1561,7 @@
                            GncOwnerType owner_type,
                            const gchar *owner_guid_str)
 {
-    GncOwner *owner=gncOwnerCreate();
+    GncOwner *owner=gncOwnerNew();
     QofBook *book;
     GncGUID owner_guid;
 

Modified: gnucash/trunk/src/optional/python-bindings/gnucash_core.i
===================================================================
--- gnucash/trunk/src/optional/python-bindings/gnucash_core.i	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/optional/python-bindings/gnucash_core.i	2011-05-11 21:51:17 UTC (rev 20621)
@@ -140,7 +140,7 @@
 
 
 %typemap(in) GncOwner * {
-    GncOwner * temp_owner = gncOwnerCreate();
+    GncOwner * temp_owner = gncOwnerNew();
     void * pointer_to_real_thing;
     if ((SWIG_ConvertPtr($input, &pointer_to_real_thing,
                          $descriptor(GncCustomer *),
@@ -176,7 +176,7 @@
 }
 
 %typemap(freearg) GncOwner * {
-    gncOwnerDestroy($1);
+    gncOwnerFree($1);
 }
 
 

Modified: gnucash/trunk/src/plugins/bi_import/bi_import.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/bi_import.c	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/plugins/bi_import/bi_import.c	2011-05-11 21:51:17 UTC (rev 20621)
@@ -552,7 +552,7 @@
             // new invoice
             invoice = gncInvoiceCreate (book);
             gncInvoiceSetID (invoice, id);
-            owner = gncOwnerCreate ();
+            owner = gncOwnerNew ();
             if (g_ascii_strcasecmp (type, "BILL") == 0)
                 gncOwnerInitVendor (owner,
                                     gnc_search_vendor_on_id (book, owner_id));

Modified: gnucash/trunk/src/report/business-reports/aging.scm
===================================================================
--- gnucash/trunk/src/report/business-reports/aging.scm	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/report/business-reports/aging.scm	2011-05-11 21:51:17 UTC (rev 20621)
@@ -181,7 +181,7 @@
 
   (define (do-update value)
     (let* ((transaction (xaccSplitGetParent split))
-	   (temp-owner (gncOwnerCreate))
+	   (temp-owner (gncOwnerNew))
 	   (owner (gnc:owner-from-split split temp-owner)))
 
       (if (not (null? owner))
@@ -218,7 +218,7 @@
 			 (process-payment company-info value))
 		     (hash-set! hash guid company-info)
 		     (cons #t guid)))
-	       (gncOwnerDestroy temp-owner))
+	       (gncOwnerFree temp-owner))
 		 
 	     ;; if it's a new company
 	     (begin
@@ -230,7 +230,7 @@
 		 (hash-set! hash guid new-company))
 	       (cons #t guid))))
        ; else (no owner)
-       (gncOwnerDestroy temp-owner))))
+       (gncOwnerFree temp-owner))))
   
   ;; figure out if this split is part of a closed lot
   ;; also save the split value...
@@ -655,7 +655,7 @@
 				    (gnc:owner-anchor-text owner)
 				    company-name))
 				  monetary-list))
-			  (gncOwnerDestroy owner)))
+			  (gncOwnerFree owner)))
 		      company-list)
 
 	    ;; add the totals

Modified: gnucash/trunk/src/report/business-reports/owner-report.scm
===================================================================
--- gnucash/trunk/src/report/business-reports/owner-report.scm	2011-05-11 21:51:03 UTC (rev 20620)
+++ gnucash/trunk/src/report/business-reports/owner-report.scm	2011-05-11 21:51:17 UTC (rev 20621)
@@ -834,14 +834,14 @@
 	 account split query journal? double? title
 	 debit-string credit-string)
 
-  (let* ((temp-owner (gncOwnerCreate))
+  (let* ((temp-owner (gncOwnerNew))
 	 (owner (gnc:owner-from-split split temp-owner))
 	 (res -1)) ;; XXX -- in this case we should create an error report
 
     (if (not (null? owner))
 	(set! res (gnc:owner-report-create owner account)))
 
-    (gncOwnerDestroy temp-owner)
+    (gncOwnerFree temp-owner)
     res))
 
 (gnc:register-report-hook ACCT-TYPE-RECEIVABLE #t



More information about the gnucash-changes mailing list