r14656 - gnucash/branches/swigify/src/business/business-utils - Further swigification of the business-utils module.

Chris Shoemaker chris at cvs.gnucash.org
Sat Aug 12 22:37:07 EDT 2006


Author: chris
Date: 2006-08-12 22:37:06 -0400 (Sat, 12 Aug 2006)
New Revision: 14656
Trac: http://svn.gnucash.org/trac/changeset/14656

Modified:
   gnucash/branches/swigify/src/business/business-utils/business-options.c
   gnucash/branches/swigify/src/business/business-utils/business-options.scm
   gnucash/branches/swigify/src/business/business-utils/business-prefs.scm
Log:
   Further swigification of the business-utils module.
   The business-options code requires wrapping types with the SWIG runtime.
   business-prefs.scm requires using '() instead of #f to mean NULL. 


Modified: gnucash/branches/swigify/src/business/business-utils/business-options.c
===================================================================
--- gnucash/branches/swigify/src/business/business-utils/business-options.c	2006-08-13 02:33:12 UTC (rev 14655)
+++ gnucash/branches/swigify/src/business/business-utils/business-options.c	2006-08-13 02:37:06 UTC (rev 14656)
@@ -26,10 +26,12 @@
 
 #include "business-options.h"
 
-#include <g-wrap-wct.h>
+//#include <g-wrap-wct.h>
+#include "swig-runtime.h"
 
+#define FUNC_NAME __FUNCTION__
 
-#define LOOKUP_OPTION(fcn) { \
+#define LOOKUP_OPTION(fcn) \
   GNCOption *option; \
   SCM getter; \
   SCM value; \
@@ -47,13 +49,11 @@
   if (value == SCM_BOOL_F) \
     return NULL; \
   \
-  if (!gw_wcp_p(value)) \
-    scm_misc_error(fcn, "Item is not a gw:wcp.", value); \
-  \
-  return gw_wcp_get_ptr(value); \
-}
-	
+  if (!SWIG_IsPointer(value)) \
+    scm_misc_error(fcn, "Item is not a gw:wcp.", value)
 
+//  return gw_wcp_get_ptr(value);
+
 GncTaxTable*
 gnc_option_db_lookup_taxtable_option(GNCOptionDB *odb,
 				     const char *section,
@@ -61,6 +61,7 @@
 				     GncTaxTable * default_value)
 {
   LOOKUP_OPTION("gnc_option_db_lookup_taxtable_option");
+  return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p_GncTaxTable"), 1, 0);
 }
 
 GncInvoice*
@@ -70,6 +71,7 @@
 				    GncInvoice * default_value)
 {
   LOOKUP_OPTION("gnc_option_db_lookup_invoice_option");
+  return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p_GncInvoice"), 1, 0);
 }
 
 GncCustomer*
@@ -79,6 +81,7 @@
 				     GncCustomer * default_value)
 {
   LOOKUP_OPTION("gnc_option_db_lookup_customer_option");
+  return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p_GncCustomer"), 1, 0);
 }
 
 GncVendor*
@@ -88,4 +91,5 @@
 				   GncVendor * default_value)
 {
   LOOKUP_OPTION("gnc_option_db_lookup_vendor_option");
+  return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p_GncVendor"), 1, 0);
 }

Modified: gnucash/branches/swigify/src/business/business-utils/business-options.scm
===================================================================
--- gnucash/branches/swigify/src/business/business-utils/business-options.scm	2006-08-13 02:33:12 UTC (rev 14655)
+++ gnucash/branches/swigify/src/business/business-utils/business-options.scm	2006-08-13 02:37:06 UTC (rev 14656)
@@ -35,11 +35,11 @@
   (define (convert-to-guid item)
     (if (string? item)
         item
-        (gnc:invoice-get-guid item)))
+        (gncInvoiceReturnGUID item)))
 
   (define (convert-to-invoice item)
     (if (string? item)
-        (gnc:invoice-lookup item (gnc:get-current-book))
+        (gncInvoiceLookupDirect item (gnc:get-current-book))
         item))
 
   (let* ((option (convert-to-guid (default-getter)))
@@ -73,7 +73,7 @@
      (gnc:restore-form-generator value->string)
      (lambda (f p) (gnc:kvp-frame-set-slot-path f option p))
      (lambda (f p)
-       (let ((v (gnc:kvp-frame-get-slot-path f p)))
+       (let ((v (kvp-frame-get-slot-path-gslist f p)))
 	 (if (and v (string? v))
 	     (begin
 	       (set! option v)
@@ -96,11 +96,11 @@
   (define (convert-to-guid item)
     (if (string? item)
         item
-        (gnc:customer-get-guid item)))
+        (gncCustomerReturnGUID item)))
 
   (define (convert-to-customer item)
     (if (string? item)
-        (gnc:customer-lookup item (gnc:get-current-book))
+        (gncCustomerLookupDirect item (gnc:get-current-book))
         item))
 
   (let* ((option (convert-to-guid (default-getter)))
@@ -134,7 +134,7 @@
      (gnc:restore-form-generator value->string)
      (lambda (f p) (gnc:kvp-frame-set-slot-path f option p))
      (lambda (f p)
-       (let ((v (gnc:kvp-frame-get-slot-path f p)))
+       (let ((v (kvp-frame-get-slot-path-gslist f p)))
 	 (if (and v (string? v))
 	     (begin
 	       (set! option v)
@@ -157,11 +157,11 @@
   (define (convert-to-guid item)
     (if (string? item)
         item
-        (gnc:vendor-get-guid item)))
+        (gncVendorReturnGUID item)))
 
   (define (convert-to-vendor item)
     (if (string? item)
-        (gnc:vendor-lookup item (gnc:get-current-book))
+        (gncVendorLookupDirect item (gnc:get-current-book))
         item))
 
   (let* ((option (convert-to-guid (default-getter)))
@@ -195,7 +195,7 @@
      (gnc:restore-form-generator value->string)
      (lambda (f p) (gnc:kvp-frame-set-slot-path f option p))
      (lambda (f p)
-       (let ((v (gnc:kvp-frame-get-slot-path f p)))
+       (let ((v (kvp-frame-get-slot-path-gslist f p)))
 	 (if (and v (string? v))
 	     (begin
 	       (set! option v)
@@ -218,11 +218,11 @@
   (define (convert-to-guid item)
     (if (string? item)
         item
-        (gnc:employee-get-guid item)))
+        (gncEmployeeReturnGUID item)))
 
   (define (convert-to-employee item)
     (if (string? item)
-        (gnc:employee-lookup item (gnc:get-current-book))
+        (gncEmployeeLookupDirect item (gnc:get-current-book))
         item))
 
   (let* ((option (convert-to-guid (default-getter)))
@@ -256,7 +256,7 @@
      (gnc:restore-form-generator value->string)
      (lambda (f p) (gnc:kvp-frame-set-slot-path f option p))
      (lambda (f p)
-       (let ((v (gnc:kvp-frame-get-slot-path f p)))
+       (let ((v (kvp-frame-get-slot-path-gslist f p)))
 	 (if (and v (string? v))
 	     (begin
 	       (set! option v)
@@ -277,41 +277,40 @@
 	 value-validator
 	 owner-type)
 
-  (let ((option-value (gnc:owner-create)))
+  (let ((option-value (gncOwnerCreate)))
 
     (define (convert-to-pair item)
       (if (pair? item)
 	  item
-	  (cons (gw:enum-<gnc:GncOwnerType>-val->sym
-		 (gnc:owner-get-type item) #f)
-		(gnc:owner-get-guid item))))
+	  (cons (gncOwnerGetType item)
+		(gncOwnerReturnGUID item))))
 
     (define (convert-to-owner pair)
       (if (pair? pair)
-	  (let ((type (gw:enum-<gnc:GncOwnerType>-val->sym (car pair) #f)))
+	  (let ((type (car pair)))
 	    (case type
-	      ((gnc-owner-customer)
+	      ((GNC-OWNER-CUSTOMER)
 	       (gnc:owner-init-customer
 		option-value
-		(gnc:customer-lookup (cdr pair) (gnc:get-current-book)))
+		(gncCustomerLookupDirect (cdr pair) (gnc:get-current-book)))
 	       option-value)
 
-	       ((gnc-owner-vendor)
+	       ((GNC-OWNER-VENDOR)
 		(gnc:owner-init-vendor
 		 option-value
-		 (gnc:vendor-lookup (cdr pair) (gnc:get-current-book)))
+		 (gncVendorLookupDirect (cdr pair) (gnc:get-current-book)))
 		option-value)
 
-	       ((gnc-owner-employee)
+	       ((GNC-OWNER-EMPLOYEE)
 		(gnc:owner-init-employee
 		 option-value
-		 (gnc:employee-lookup (cdr pair) (gnc:get-current-book)))
+		 (gncEmployeeLookupDirect (cdr pair) (gnc:get-current-book)))
 		option-value)
 
-	       ((gnc-owner-job)
+	       ((GNC-OWNER-JOB)
 		(gnc:owner-init-job
 		 option-value
-		 (gnc:job-lookup (cdr pair) (gnc:get-current-book)))
+		 (gncJobLookupDirect (cdr pair) (gnc:get-current-book)))
 		option-value)
 
 	       (else #f)))
@@ -330,10 +329,9 @@
 	   (validator
 	    (if (not value-validator)
 		(lambda (owner)
-		  (let ((type (gw:enum-<gnc:GncOwnerType>-val->sym
-			       (if (pair? owner)
+		  (let ((type (if (pair? owner)
 				   (car owner)
-				   (gnc:owner-get-type owner)) #f)))
+				   (gncOwnerGetType owner))))
 		    (if (equal? type owner-type)
 			(list #t owner)
 			(list #f "Owner-Type Mismatch"))))
@@ -361,8 +359,8 @@
 	 (gnc:kvp-frame-set-slot-path f (cdr option)
 				      (append p '("value"))))
        (lambda (f p)
-	 (let ((t (gnc:kvp-frame-get-slot-path f (append p '("type"))))
-	       (v (gnc:kvp-frame-get-slot-path f (append p '("value")))))
+	 (let ((t (kvp-frame-get-slot-path-gslist f (append p '("type"))))
+	       (v (kvp-frame-get-slot-path-gslist f (append p '("value")))))
 	   (if (and t v (string? t) (string? v))
 	       (begin
 		 (set! option (cons (string->symbol t) v))
@@ -386,11 +384,11 @@
   (define (convert-to-guid item)
     (if (string? item)
         item
-        (gnc:taxtable-get-guid item)))
+        (gncTaxTableReturnGUID item)))
 
   (define (convert-to-taxtable item)
     (if (string? item)
-        (gnc:taxtable-lookup item (gnc:get-current-book))
+        (gncTaxTableLookupDirect item (gnc:get-current-book))
         item))
 
   (let* ((option (convert-to-guid (default-getter)))
@@ -424,7 +422,7 @@
      (gnc:restore-form-generator value->string)
      (lambda (f p) (gnc:kvp-frame-set-slot-path f option p))
      (lambda (f p)
-       (let ((v (gnc:kvp-frame-get-slot-path f p)))
+       (let ((v (kvp-frame-get-slot-path-gslist f p)))
 	 (if (and v (string? v))
 	     (begin
 	       (set! option v)

Modified: gnucash/branches/swigify/src/business/business-utils/business-prefs.scm
===================================================================
--- gnucash/branches/swigify/src/business/business-utils/business-prefs.scm	2006-08-13 02:33:12 UTC (rev 14655)
+++ gnucash/branches/swigify/src/business/business-utils/business-prefs.scm	2006-08-13 02:37:06 UTC (rev 14656)
@@ -68,13 +68,13 @@
    (gnc:make-taxtable-option
     gnc:*business-label* (N_ "Default Customer TaxTable")
     "e" (N_ "The default tax table to apply to customers.")
-    (lambda () #f) #f))
+    (lambda () '()) #f))
 
   (reg-option
    (gnc:make-taxtable-option
     gnc:*business-label* (N_ "Default Vendor TaxTable")
     "f" (N_ "The default tax table to apply to vendors.")
-    (lambda () #f) #f))
+    (lambda () '()) #f))
 
   (reg-option
    (gnc:make-dateformat-option



More information about the gnucash-changes mailing list