r14686 - gnucash/branches/swigify/src/business - Fix the scm-side treatment of the enum constants.

Chris Shoemaker chris at cvs.gnucash.org
Tue Aug 15 23:45:45 EDT 2006


Author: chris
Date: 2006-08-15 23:45:44 -0400 (Tue, 15 Aug 2006)
New Revision: 14686
Trac: http://svn.gnucash.org/trac/changeset/14686

Modified:
   gnucash/branches/swigify/src/business/business-reports/business-reports.scm
   gnucash/branches/swigify/src/business/business-reports/easy-invoice.scm
   gnucash/branches/swigify/src/business/business-reports/fancy-invoice.scm
   gnucash/branches/swigify/src/business/business-reports/invoice.scm
   gnucash/branches/swigify/src/business/business-reports/owner-report.scm
   gnucash/branches/swigify/src/business/business-utils/business-options.scm
Log:
   Fix the scm-side treatment of the enum constants.
   Revert back to using the g-wrapped versions of some functions in engine. 


Modified: gnucash/branches/swigify/src/business/business-reports/business-reports.scm
===================================================================
--- gnucash/branches/swigify/src/business/business-reports/business-reports.scm	2006-08-16 03:41:56 UTC (rev 14685)
+++ gnucash/branches/swigify/src/business/business-reports/business-reports.scm	2006-08-16 03:45:44 UTC (rev 14686)
@@ -54,17 +54,17 @@
 
 (define (gnc:owner-anchor-text owner)
   (let ((type (gncOwnerGetType (gncOwnerGetEndOwner owner))))
-    (case type
-      ((GNC-OWNER-CUSTOMER)
+    (cond 
+      ((eqv? type (GNC-OWNER-CUSTOMER))
        (gnc:customer-anchor-text (gncOwnerGetCustomer owner)))
 
-      ((GNC-OWNER-VENDOR)
+      ((eqv? type (GNC-OWNER-VENDOR))
        (gnc:vendor-anchor-text (gncOwnerGetVendor owner)))
 
-      ((GNC-OWNER-EMPLOYEE)
+      ((eqv? type (GNC-OWNER-EMPLOYEE))
        (gnc:employee-anchor-text (gncOwnerGetEmployee owner)))
 
-      ((GNC-OWNER-JOB)
+      ((eqv? type (GNC-OWNER-JOB))
        (gnc:job-anchor-text (gncOwnerGetJob owner)))
 
       (else
@@ -75,14 +75,14 @@
 	 (type (gncOwnerGetType end-owner))
 	 (ref #f))
 
-    (case type
-      ((GNC-OWNER-CUSTOMER)
+    (cond
+      ((eqv? type (GNC-OWNER-CUSTOMER))
        (set! ref "owner=c:"))
 
-      ((GNC-OWNER-VENDOR)
+      ((eqv? type (GNC-OWNER-VENDOR))
        (set! ref "owner=v:"))
 
-      ((GNC-OWNER-EMPLOYEE)
+      ((eqv? type (GNC-OWNER-EMPLOYEE))
        (set! ref "owner=e:"))
 
       (else (set! ref "unknown-type=")))

Modified: gnucash/branches/swigify/src/business/business-reports/easy-invoice.scm
===================================================================
--- gnucash/branches/swigify/src/business/business-reports/easy-invoice.scm	2006-08-16 03:41:56 UTC (rev 14685)
+++ gnucash/branches/swigify/src/business/business-reports/easy-invoice.scm	2006-08-16 03:45:44 UTC (rev 14686)
@@ -624,11 +624,11 @@
 
 (define (make-myname-table book)
   (let* ((table (gnc:make-html-table))
-	 (slots (gnc-book-get-slots book))
-	 (name (kvp-frame-get-slot-path-gslist
+	 (slots (gnc:book-get-slots book))
+	 (name (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-name*))))
-	 (addy (kvp-frame-get-slot-path-gslist
+	 (addy (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-addy*)))))
 
@@ -688,12 +688,12 @@
 	  (set! owner (gncInvoiceGetOwner invoice))
 	  (let ((type (gncOwnerGetType 
 			(gncOwnerGetEndOwner owner))))
-	    (case type
-	      ((GNC-OWNER-CUSTOMER)
+	    (cond
+	      ((eqv? type (GNC-OWNER-CUSTOMER))
 	       (set! invoice? #t))
-	      ((GNC-OWNER-VENDOR)
+	      ((eqv? type (GNC-OWNER-VENDOR))
 	       (set! title (_ "Bill")))
-	      ((GNC-OWNER-EMPLOYEE)
+	      ((eqv? type (GNC-OWNER-EMPLOYEE))
 	       (set! title (_ "Expense Voucher")))))
 	  (set! title (sprintf #f (_"%s #%d") title
 			       (gncInvoiceGetID invoice)))))
@@ -720,8 +720,8 @@
 
         (if (opt-val "Display" "My Company ID")
           (let* ((book (gncInvoiceGetBook invoice))
-                 (slots (gnc-book-get-slots book))
-	         (taxid (kvp-frame-get-slot-path-gslist
+                 (slots (gnc:book-get-slots book))
+	         (taxid (gnc:kvp-frame-get-slot-path
 		    slots (append gnc:*kvp-option-path*
 		                  (list gnc:*business-label* gnc:*company-id*)))))
                  (if (and taxid (> (string-length taxid) 0))

Modified: gnucash/branches/swigify/src/business/business-reports/fancy-invoice.scm
===================================================================
--- gnucash/branches/swigify/src/business/business-reports/fancy-invoice.scm	2006-08-16 03:41:56 UTC (rev 14685)
+++ gnucash/branches/swigify/src/business/business-reports/fancy-invoice.scm	2006-08-16 03:45:44 UTC (rev 14686)
@@ -665,26 +665,26 @@
 
 (define (make-myname-table book date-format)
   (let* ((table (gnc:make-html-table))
-	 (slots (gnc-book-get-slots book))
-	 (name (kvp-frame-get-slot-path-gslist
+	 (slots (gnc:book-get-slots book))
+	 (name (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-name*))))
-;;	 (contact (kvp-frame-get-slot-path-gslist
+;;	 (contact (gnc:kvp-frame-get-slot-path
 ;;		slots (append gnc:*kvp-option-path*
 ;;			      (list gnc:*business-label* gnc:*company-contact*))))
-	 (addy (kvp-frame-get-slot-path-gslist
+	 (addy (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-addy*))))
-	 (id (kvp-frame-get-slot-path-gslist
+	 (id (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-id*))))
-	 (phone (kvp-frame-get-slot-path-gslist
+	 (phone (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-phone*))))
-	 (fax (kvp-frame-get-slot-path-gslist
+	 (fax (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-fax*))))
-	 (url (kvp-frame-get-slot-path-gslist
+	 (url (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-url*))))
 	 (invoice-cell (gnc:make-html-table-cell))
@@ -771,12 +771,12 @@
 	  (set! owner (gncInvoiceGetOwner invoice))
 	  (let ((type (gncOwnerGetType 
 			(gncOwnerGetEndOwner owner))))
-	    (case type
-	      ((GNC-OWNER-CUSTOMER)
+	    (cond
+	      ((eqv? type (GNC-OWNER-CUSTOMER))
 	       (set! invoice? #t))
-	      ((GNC-OWNER-VENDOR)
+	      ((eqv? type (GNC-OWNER-VENDOR))
 	       (set! title (_ "Bill")))
-	      ((GNC-OWNER-EMPLOYEE)
+	      ((eqv? type (GNC-OWNER-EMPLOYEE))
 	       (set! title (_ "Expense Voucher")))))
 	  (set! title (sprintf #f (_"%s #%d") title
 			       (gncInvoiceGetID invoice)))))
@@ -786,7 +786,7 @@
 
     (if invoice
 	(let* ((book (gncInvoiceGetBook invoice))
-	      (slots (gnc-book-get-slots book))
+	      (slots (gnc:book-get-slots book))
 	      (date-object #f)
 	      (helper-table (gnc:make-html-table)))
 	  (set! table (make-entry-table invoice
@@ -914,7 +914,7 @@
 	  (make-break! document)
 
 	  (if (opt-val "Display" "Payable to")
-	      (let* ((name (kvp-frame-get-slot-path-gslist
+	      (let* ((name (gnc:kvp-frame-get-slot-path
 			    slots (append gnc:*kvp-option-path*
 					  (list gnc:*business-label*
 						gnc:*company-name*))))
@@ -929,7 +929,7 @@
 	  (make-break! document)
 
 	  (if (opt-val "Display" "Company contact")
-	      (let* ((contact (kvp-frame-get-slot-path-gslist
+	      (let* ((contact (gnc:kvp-frame-get-slot-path
 			       slots (append gnc:*kvp-option-path*
 					     (list gnc:*business-label*
 						   gnc:*company-contact*))))

Modified: gnucash/branches/swigify/src/business/business-reports/invoice.scm
===================================================================
--- gnucash/branches/swigify/src/business/business-reports/invoice.scm	2006-08-16 03:41:56 UTC (rev 14685)
+++ gnucash/branches/swigify/src/business/business-reports/invoice.scm	2006-08-16 03:45:44 UTC (rev 14686)
@@ -587,11 +587,11 @@
 
 (define (make-myname-table book date-format)
   (let* ((table (gnc:make-html-table))
-	 (slots (gnc-book-get-slots book))
-	 (name (kvp-frame-get-slot-path-gslist
+	 (slots (gnc:book-get-slots book))
+	 (name (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-name*))))
-	 (addy (kvp-frame-get-slot-path-gslist
+	 (addy (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-addy*)))))
 
@@ -641,12 +641,12 @@
 	  (set! owner (gncInvoiceGetOwner invoice))
 	  (let ((type (gncOwnerGetType 
 			(gncOwnerGetEndOwner owner))))
-	    (case type
-	      ((GNC-OWNER-CUSTOMER)
+	    (cond
+	      ((eqv? type (GNC-OWNER-CUSTOMER))
 	       (set! invoice? #t))
-	      ((GNC-OWNER-VENDOR)
+	      ((eqv? type (GNC-OWNER-VENDOR))
 	       (set! title (_ "Bill")))
-	      ((GNC-OWNER-EMPLOYEE)
+	      ((eqv? type (GNC-OWNER-EMPLOYEE))
 	       (set! title (_ "Expense Voucher")))))
 	  (set! title (sprintf #f (_"%s #%d") title
 			       (gncInvoiceGetID invoice)))))

Modified: gnucash/branches/swigify/src/business/business-reports/owner-report.scm
===================================================================
--- gnucash/branches/swigify/src/business/business-reports/owner-report.scm	2006-08-16 03:41:56 UTC (rev 14685)
+++ gnucash/branches/swigify/src/business/business-reports/owner-report.scm	2006-08-16 03:45:44 UTC (rev 14686)
@@ -403,13 +403,13 @@
   gnc:*report-options*)
 	     
 (define (customer-options-generator)
-  (options-generator '(receivable) GNC-OWNER-CUSTOMER (_ "Invoice") #f))
+  (options-generator '(receivable) (GNC-OWNER-CUSTOMER) (_ "Invoice") #f))
 
 (define (vendor-options-generator)
-  (options-generator '(payable) GNC-OWNER-VENDOR (_ "Bill") #t))
+  (options-generator '(payable) (GNC-OWNER-VENDOR) (_ "Bill") #t))
 
 (define (employee-options-generator)
-  (options-generator '(payable) GNC-OWNER-EMPLOYEE (_ "Expense Report") #t))
+  (options-generator '(payable) (GNC-OWNER-EMPLOYEE) (_ "Expense Report") #t))
 
 (define (string-expand string character replace-string)
   (define (car-line chars)
@@ -491,11 +491,11 @@
 
 (define (make-myname-table book date-format)
   (let* ((table (gnc:make-html-table))
-	 (slots (gnc-book-get-slots book))
-	 (name (kvp-frame-get-slot-path-gslist
+	 (slots (gnc:book-get-slots book))
+	 (name (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-name*))))
-	 (addy (kvp-frame-get-slot-path-gslist
+	 (addy (gnc:kvp-frame-get-slot-path
 		slots (append gnc:*kvp-option-path*
 			      (list gnc:*business-label* gnc:*company-addy*)))))
 
@@ -544,14 +544,15 @@
 	 (owner-type (opt-val "__reg" "owner-type"))
 	 (type-str ""))
 
-    (case owner-type
-      ((GNC-OWNER-CUSTOMER)
-       (set! type-str (N_ "Customer")))
-      ((GNC-OWNER-VENDOR)
-       (set! type-str (N_ "Vendor")))
-      ((GNC-OWNER-EMPLOYEE)
-       (set! type-str (N_ "Employee"))))
-
+    (cond
+     ((eqv? owner-type (GNC-OWNER-CUSTOMER))
+      (set! type-str (N_ "Customer")))
+     ((eqv? owner-type (GNC-OWNER-VENDOR))
+      (gnc:error "got here")
+      (set! type-str (N_ "Vendor")))
+     ((eqv? owner-type (GNC-OWNER-EMPLOYEE))
+      (set! type-str (N_ "Employee"))))
+    
     (gnc:html-document-set-title!
      document (string-append (_ type-str) " " (_ "Report")))
 
@@ -622,6 +623,7 @@
     (gnc:free-query query)
     document))
 
+;; FIXME: remember to replace #f's with '() when Account * is swig-wrapped.
 (define (find-first-account type)
   (define (find-first group num index)
     (if (>= index num)
@@ -642,21 +644,21 @@
 
 (define (find-first-account-for-owner owner)
   (let ((type (gncOwnerGetType (gncOwnerGetEndOwner owner))))
-    (case type
-      ((GNC-OWNER-CUSTOMER)
+    (cond
+      ((eqv? type (GNC-OWNER-CUSTOMER))
        (find-first-account 'receivable))
 
-      ((GNC-OWNER-VENDOR)
+      ((eqv? type (GNC-OWNER-VENDOR))
        (find-first-account 'payable))
 
-      ((GNC-OWNER-EMPLOYEE)
+      ((eqv? type (GNC-OWNER-EMPLOYEE))
        (find-first-account 'payable))
 
-      ((GNC-OWNER-JOB)
+      ((eqv? type (GNC-OWNER-JOB))
        (find-first-account-for-owner (gncOwnerGetEndOwner owner)))
 
       (else
-       #f))))
+       #f))))  ;;FIXME: remember to convert
 
 (gnc:define-report
  'version 1
@@ -693,14 +695,14 @@
 
 (define (owner-report-create owner account)
   (let ((type (gncOwnerGetType (gncOwnerGetEndOwner owner))))
-    (case type
-      ((GNC-OWNER-CUSTOMER)
+    (cond
+      ((eqv? type (GNC-OWNER-CUSTOMER))
        (owner-report-create-internal (N_ "Customer Report") owner account))
 
-      ((GNC-OWNER-VENDOR)
+      ((eqv? type (GNC-OWNER-VENDOR))
        (owner-report-create-internal (N_ "Vendor Report") owner account))
 
-      ((GNC-OWNER-EMPLOYEE)
+      ((eqv? type (GNC-OWNER-EMPLOYEE))
        (owner-report-create-internal (N_ "Employee Report") owner account))
 
       (else #f))))

Modified: gnucash/branches/swigify/src/business/business-utils/business-options.scm
===================================================================
--- gnucash/branches/swigify/src/business/business-utils/business-options.scm	2006-08-16 03:41:56 UTC (rev 14685)
+++ gnucash/branches/swigify/src/business/business-utils/business-options.scm	2006-08-16 03:45:44 UTC (rev 14686)
@@ -23,7 +23,6 @@
 ;; Internally, values are always a guid. Externally, both guids and
 ;; invoice pointers may be used to set the value of the option. The
 ;; option always returns a single invoice pointer.
-
 (define (gnc:make-invoice-option
 	 section
 	 name
@@ -39,7 +38,7 @@
 
   (define (convert-to-invoice item)
     (if (string? item)
-        (gncInvoiceLookupDirect item (gnc:get-current-book))
+        (gncInvoiceLookupFlip item (gnc:get-current-book))
         item))
 
   (let* ((option (convert-to-guid (default-getter)))
@@ -73,7 +72,7 @@
      (gnc:restore-form-generator value->string)
      (lambda (f p) (gnc:kvp-frame-set-slot-path f option p))
      (lambda (f p)
-       (let ((v (kvp-frame-get-slot-path-gslist f p)))
+       (let ((v (gnc:kvp-frame-get-slot-path f p)))
 	 (if (and v (string? v))
 	     (begin
 	       (set! option v)
@@ -100,7 +99,7 @@
 
   (define (convert-to-customer item)
     (if (string? item)
-        (gncCustomerLookupDirect item (gnc:get-current-book))
+        (gncCustomerLookupFlip item (gnc:get-current-book))
         item))
 
   (let* ((option (convert-to-guid (default-getter)))
@@ -134,7 +133,7 @@
      (gnc:restore-form-generator value->string)
      (lambda (f p) (gnc:kvp-frame-set-slot-path f option p))
      (lambda (f p)
-       (let ((v (kvp-frame-get-slot-path-gslist f p)))
+       (let ((v (gnc:kvp-frame-get-slot-path f p)))
 	 (if (and v (string? v))
 	     (begin
 	       (set! option v)
@@ -161,7 +160,7 @@
 
   (define (convert-to-vendor item)
     (if (string? item)
-        (gncVendorLookupDirect item (gnc:get-current-book))
+        (gncVendorLookupFlip item (gnc:get-current-book))
         item))
 
   (let* ((option (convert-to-guid (default-getter)))
@@ -195,7 +194,7 @@
      (gnc:restore-form-generator value->string)
      (lambda (f p) (gnc:kvp-frame-set-slot-path f option p))
      (lambda (f p)
-       (let ((v (kvp-frame-get-slot-path-gslist f p)))
+       (let ((v (gnc:kvp-frame-get-slot-path f p)))
 	 (if (and v (string? v))
 	     (begin
 	       (set! option v)
@@ -222,7 +221,7 @@
 
   (define (convert-to-employee item)
     (if (string? item)
-        (gncEmployeeLookupDirect item (gnc:get-current-book))
+        (gncEmployeeLookupFlip item (gnc:get-current-book))
         item))
 
   (let* ((option (convert-to-guid (default-getter)))
@@ -256,7 +255,7 @@
      (gnc:restore-form-generator value->string)
      (lambda (f p) (gnc:kvp-frame-set-slot-path f option p))
      (lambda (f p)
-       (let ((v (kvp-frame-get-slot-path-gslist f p)))
+       (let ((v (gnc:kvp-frame-get-slot-path f p)))
 	 (if (and v (string? v))
 	     (begin
 	       (set! option v)
@@ -288,32 +287,32 @@
     (define (convert-to-owner pair)
       (if (pair? pair)
 	  (let ((type (car pair)))
-	    (case type
-	      ((GNC-OWNER-CUSTOMER)
-	       (gnc:owner-init-customer
+	    (cond
+	      ((eqv? type (GNC-OWNER-CUSTOMER))
+	       (gncOwnerInitCustomer
 		option-value
-		(gncCustomerLookupDirect (cdr pair) (gnc:get-current-book)))
+		(gncCustomerLookupFlip (cdr pair) (gnc:get-current-book)))
 	       option-value)
 
-	       ((GNC-OWNER-VENDOR)
-		(gnc:owner-init-vendor
+	       ((eqv? type (GNC-OWNER-VENDOR))
+		(gncOwnerInitVendor
 		 option-value
-		 (gncVendorLookupDirect (cdr pair) (gnc:get-current-book)))
+		 (gncVendorLookupFlip (cdr pair) (gnc:get-current-book)))
 		option-value)
 
-	       ((GNC-OWNER-EMPLOYEE)
-		(gnc:owner-init-employee
+	       ((eqv? type (GNC-OWNER-EMPLOYEE))
+		(gncOwnerInitEmployee
 		 option-value
-		 (gncEmployeeLookupDirect (cdr pair) (gnc:get-current-book)))
+		 (gncEmployeeLookupFlip (cdr pair) (gnc:get-current-book)))
 		option-value)
 
-	       ((GNC-OWNER-JOB)
-		(gnc:owner-init-job
+	       ((eqv? type (GNC-OWNER-JOB))
+		(GncOwnerInitJob
 		 option-value
-		 (gncJobLookupDirect (cdr pair) (gnc:get-current-book)))
+		 (gncJobLookupFlip (cdr pair) (gnc:get-current-book)))
 		option-value)
 
-	       (else #f)))
+	       (else '())))
 	  pair))
 
     (let* ((option (convert-to-pair (default-getter)))
@@ -328,6 +327,7 @@
 				  (if option-set option #f)))))
 	   (validator
 	    (if (not value-validator)
+                ;; this is the default value-validator, if none is given
 		(lambda (owner)
 		  (let ((type (if (pair? owner)
 				   (car owner)
@@ -359,8 +359,8 @@
 	 (gnc:kvp-frame-set-slot-path f (cdr option)
 				      (append p '("value"))))
        (lambda (f p)
-	 (let ((t (kvp-frame-get-slot-path-gslist f (append p '("type"))))
-	       (v (kvp-frame-get-slot-path-gslist f (append p '("value")))))
+	 (let ((t (gnc:kvp-frame-get-slot-path f (append p '("type"))))
+	       (v (gnc:kvp-frame-get-slot-path f (append p '("value")))))
 	   (if (and t v (string? t) (string? v))
 	       (begin
 		 (set! option (cons (string->symbol t) v))
@@ -388,7 +388,7 @@
 
   (define (convert-to-taxtable item)
     (if (string? item)
-        (gncTaxTableLookupDirect item (gnc:get-current-book))
+        (gncTaxTableLookupFlip item (gnc:get-current-book))
         item))
 
   (let* ((option (convert-to-guid (default-getter)))
@@ -422,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 (kvp-frame-get-slot-path-gslist f p)))
+       (let ((v (gnc:kvp-frame-get-slot-path f p)))
 	 (if (and v (string? v))
 	     (begin
 	       (set! option v)



More information about the gnucash-changes mailing list