r14653 - gnucash/branches/swigify/src/business/business-core - Further conversion of the business-core module to swig.

Chris Shoemaker chris at cvs.gnucash.org
Sat Aug 12 22:28:21 EDT 2006


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

Modified:
   gnucash/branches/swigify/src/business/business-core/Makefile.am
   gnucash/branches/swigify/src/business/business-core/business-core.i
   gnucash/branches/swigify/src/business/business-core/business-core.scm
   gnucash/branches/swigify/src/business/business-core/gncBillTerm.h
   gnucash/branches/swigify/src/business/business-core/gncEntry.c
   gnucash/branches/swigify/src/business/business-core/gncEntry.h
   gnucash/branches/swigify/src/business/business-core/gncInvoice.c
   gnucash/branches/swigify/src/business/business-core/gncInvoice.h
Log:
   Further conversion of the business-core module to swig.
   Removing all g-wrap bindings for this module.


Modified: gnucash/branches/swigify/src/business/business-core/Makefile.am
===================================================================
--- gnucash/branches/swigify/src/business/business-core/Makefile.am	2006-08-13 02:03:32 UTC (rev 14652)
+++ gnucash/branches/swigify/src/business/business-core/Makefile.am	2006-08-13 02:28:21 UTC (rev 14653)
@@ -67,8 +67,10 @@
 
 # business-core-helpers.c
 
-swig-business-core.c: business-core.i
-	swig -guile $(SWIG_ARGS) -Linkage module -o $@ $<
+swig-business-core.c: business-core.i ${libgncmod_business_core_la_SOURCES} \
+	${noinst_HEADERS}
+	swig -guile $(SWIG_ARGS) -Linkage module \
+	-I${top_srcdir}/src/engine -o $@ $<
 
 gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
 gncmod_DATA = business-core.scm

Modified: gnucash/branches/swigify/src/business/business-core/business-core.i
===================================================================
--- gnucash/branches/swigify/src/business/business-core/business-core.i	2006-08-13 02:03:32 UTC (rev 14652)
+++ gnucash/branches/swigify/src/business/business-core/business-core.i	2006-08-13 02:28:21 UTC (rev 14653)
@@ -3,7 +3,7 @@
 /* Includes the header in the wrapper code */
 #include <config.h>
 #include <gncAddress.h> 
-//#include <gncBillTerm.h>
+#include <gncBillTerm.h>
 #include <gncCustomer.h>
 #include <gncEmployee.h>
 #include <gncEntry.h>
@@ -15,32 +15,60 @@
 #include <gncVendor.h>
 #include <gncBusGuile.h>
 #include "engine-helpers.h"
+#include "gncBusGuile.h"
 %}
 
-// useless. :(
-//%rename(gnc_invoice_get_guid) gncInvoiceRetGUID;
+%import "engine.i"
 
-/* Convert from Guile --> C */
-%typemap(in) GUID {
-    $1 = gnc_scm2guid($input);
-}
+%rename(gncOwnerReturnGUID) gncOwnerRetGUID;
 
-/* Convert from C --> Guile */
-%typemap(out) GUID {
-    $result = gnc_guid2scm($1);
+%inline %{
+GUID gncTaxTableReturnGUID(GncTaxTable *x)
+{ return (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())); }
+GUID gncInvoiceReturnGUID(GncInvoice *x)
+{ return (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())); }
+GUID gncJobReturnGUID(GncJob *x)
+{ return (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())); }
+GUID gncVendorReturnGUID(GncVendor *x)
+{ return (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())); }
+GUID gncCustomerReturnGUID(GncCustomer *x)
+{ return (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())); }
+GUID gncEmployeeReturnGUID(GncEmployee *x)
+{ return (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null())); }
+%}
+
+//%typemap(in) EntryList {
+//}
+
+%typemap(out) EntryList {
+  SCM list = SCM_EOL;
+  GList *node;
+
+  for (node = $1; node; node = node->next)
+    list = scm_cons(SWIG_NewPointerObj(node->data, 
+        SWIGTYPE_p__gncEntry, 0), list);
+
+  $result = scm_reverse(list);
 }
 
-/*
-%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
-  if (SCM_FALSE_P($input)) {
-      $1 = ($1_ltype)(SWIG_MustGetP
-  $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0);
+%typemap(out) AccountValueList {
+  SCM list = SCM_EOL;
+  GList *node;
+
+  for (node = $1; node; node = node->next)
+    list = scm_cons(SWIG_NewPointerObj(node->data, 
+        SWIGTYPE_p__gncAccountValue, 0), list);
+
+  $result = scm_reverse(list);
 }
-*/
 
+%typemap(in) GncAccountValue * "$1 = gnc_scm_to_account_value_ptr($input);"
+%typemap(out) GncAccountValue * "$result = gnc_account_value_ptr_to_scm($1);"
+
+
 /* Parse the header file to generate wrappers */
 %include <gncAddress.h> 
-//%include <gncBillTerm.h>
+%include <gncBillTerm.h>
 %include <gncCustomer.h>
 %include <gncEmployee.h>
 %include <gncEntry.h>

Modified: gnucash/branches/swigify/src/business/business-core/business-core.scm
===================================================================
--- gnucash/branches/swigify/src/business/business-core/business-core.scm	2006-08-13 02:03:32 UTC (rev 14652)
+++ gnucash/branches/swigify/src/business/business-core/business-core.scm	2006-08-13 02:28:21 UTC (rev 14653)
@@ -1,25 +1,26 @@
 (define-module (gnucash business-core))
-(use-modules (g-wrapped gw-business-core))
+;;(use-modules (g-wrapped gw-business-core))
+(use-modules (sw_business_core))
 (use-modules (gnucash gnc-module))
 (gnc:module-load "gnucash/engine" 0)
 
 (define (gnc:owner-get-address owner)
-  (let ((type (gw:enum-<gnc:GncOwnerType>-val->sym
-	       (gnc:owner-get-type owner) #f)))
+  (let ((type (gncOwnerGetType owner)))
+    (display owner) (newline) (newline)
     (case type
-      ((gnc-owner-customer)
-       (let ((c (gnc:owner-get-customer owner)))
-	 (gnc:customer-get-addr c)))
-      ((gnc-owner-vendor)
-       (let ((v (gnc:owner-get-vendor owner)))
-	 (gnc:vendor-get-addr v)))
-      ((gnc-owner-employee)
-       (let ((e (gnc:owner-get-employee owner)))
-	 (gnc:employee-get-addr e)))
-      ((gnc-owner-job)
+      ((GNC-OWNER-CUSTOMER)
+       (let ((c (gncOwnerGetCustomer owner)))
+	 (gncCustomerGetAddr c)))
+      ((GNC-OWNER-VENDOR)
+       (let ((v (gncOwnerGetVendor owner)))
+	 (gncVendorGetAddr v)))
+      ((GNC-OWNER-EMPLOYEE)
+       (let ((e (gncOwnerGetEmployee owner)))
+	 (gncEmployeeGetAddr e)))
+      ((GNC-OWNER-JOB)
        (gnc:owner-get-address (gnc:job-get-owner
-			       (gnc:owner-get-job owner))))
-      (else ""))))
+			       (gncOwnerGetJob owner))))
+      (else '()))))
 
 ;
 ; The -dep functions return combined strings of the appropriate
@@ -36,13 +37,12 @@
   (define (just-name name)
     (if name name ""))
 
-  (let ((type (gw:enum-<gnc:GncOwnerType>-val->sym
-	       (gnc:owner-get-type owner) #f)))
+  (let ((type (gncOwnerGetType owner)))
     (case type
-      ((gnc-owner-job)
+      ((GNC-OWNER-JOB)
        (gnc:owner-get-name-dep (gnc:job-get-owner
-				(gnc:owner-get-job owner))))
-      (else (just-name (gnc:owner-get-name owner))))))
+				(gncOwnerGetJob owner))))
+      (else (just-name (gncOwnerGetName owner))))))
 
 (define (gnc:owner-get-address-dep owner)
   (define (add-if-exists lst new)
@@ -56,10 +56,10 @@
      (else (string-append (build-string (cdr lst)) "\n" (car lst)))))
   (let ((lst '())
 	(addr (gnc:owner-get-address owner)))
-    (set! lst (add-if-exists lst (gnc:address-get-addr1 addr)))
-    (set! lst (add-if-exists lst (gnc:address-get-addr2 addr)))
-    (set! lst (add-if-exists lst (gnc:address-get-addr3 addr)))
-    (set! lst (add-if-exists lst (gnc:address-get-addr4 addr)))
+    (set! lst (add-if-exists lst (gncAddressGetAddr1 addr)))
+    (set! lst (add-if-exists lst (gncAddressGetAddr2 addr)))
+    (set! lst (add-if-exists lst (gncAddressGetAddr3 addr)))
+    (set! lst (add-if-exists lst (gncAddressGetAddr4 addr)))
     (build-string lst)))
 
 (define (gnc:owner-get-name-and-address-dep owner)
@@ -70,45 +70,44 @@
 	addr)))
 
 (define (gnc:owner-get-owner-id owner)
-  (let ((type (gw:enum-<gnc:GncOwnerType>-val->sym
-	       (gnc:owner-get-type owner) #f)))
+  (let ((type (gncOwnerGetType owner)))
     (case type
-      ((gnc-owner-customer)
-       (let ((c (gnc:owner-get-customer owner)))
-	 (gnc:customer-get-id c)))
-      ((gnc-owner-vendor)
-       (let ((v (gnc:owner-get-vendor owner)))
-	 (gnc:vendor-get-id v)))
-      ((gnc-owner-employee)
-       (let ((e (gnc:owner-get-employee owner)))
-	 (gnc:employee-get-id e)))
-      ((gnc-owner-job)
-       (gnc:owner-get-owner-id (gnc:job-get-owner (gnc:owner-get-job owner))))
+      ((GNC-OWNER-CUSTOMER)
+       (let ((c (gncOwnerGetCustomer owner)))
+	 (gncCustomerGetID c)))
+      ((GNC-OWNER-VENDOR)
+       (let ((v (gncOwnerGetVendor owner)))
+	 (gncVendorGetID v)))
+      ((GNC-OWNER-EMPLOYEE)
+       (let ((e (gncOwnerGetEmployee owner)))
+	 (gncEmployeeGetID e)))
+      ((GNC-OWNER-JOB)
+       (gnc:owner-get-owner-id (gncJobGetOwner (gncOwnerGetJob owner))))
       (else ""))))
 
 (define (gnc:entry-type-percent-p type-val)
-  (let ((type (gw:enum-<gnc:GncAmountType>-val->sym type-val #f)))
+  (let ((type type-val))
     (equal? type 'gnc-amount-type-percent)))
 
 (define (gnc:owner-from-split split result-owner)
   (let* ((trans (gnc:split-get-parent split))
-	 (invoice (gnc:invoice-get-invoice-from-txn trans))
-	 (temp-owner (gnc:owner-create))
+	 (invoice (gncInvoiceGetInvoiceFromTxn trans))
+	 (temp-owner (gncOwnerCreate))
 	 (owner #f))
 
     (if invoice
-	(set! owner (gnc:invoice-get-owner invoice))
+	(set! owner (gncInvoiceGetOwner invoice))
 	(let ((split-list (gnc:transaction-get-splits trans)))
 	  (define (check-splits splits)
 	    (if (and splits (not (null? splits)))
 		(let* ((split (car splits))
 		       (lot (gnc:split-get-lot split)))
 		  (if lot
-		      (let* ((invoice (gnc:invoice-get-invoice-from-lot lot))
+		      (let* ((invoice (gncInvoiceGetInvoiceFromLot lot))
 			     (owner? (gnc:owner-get-owner-from-lot
 				      lot temp-owner)))
 			(if invoice
-			    (set! owner (gnc:invoice-get-owner invoice))
+			    (set! owner (gncInvoiceGetOwner invoice))
 			    (if owner?
 				(set! owner temp-owner)
 				(check-splits (cdr splits)))))
@@ -117,11 +116,11 @@
 
     (if owner
 	(begin
-	  (gnc:owner-copy-into-owner (gnc:owner-get-end-owner owner) result-owner)
-	  (gnc:owner-destroy temp-owner)
+	  (gncOwnerCopy (gncOwnerGetEndOwner owner) result-owner)
+	  (gncOwnerDestroy temp-owner)
 	  result-owner)
 	(begin
-	  (gnc:owner-destroy temp-owner)
+	  (gncOwnerDestroy temp-owner)
 	  #f))))
 
 

Modified: gnucash/branches/swigify/src/business/business-core/gncBillTerm.h
===================================================================
--- gnucash/branches/swigify/src/business/business-core/gncBillTerm.h	2006-08-13 02:03:32 UTC (rev 14652)
+++ gnucash/branches/swigify/src/business/business-core/gncBillTerm.h	2006-08-13 02:28:21 UTC (rev 14653)
@@ -59,17 +59,19 @@
  * ??? huh?
  * NOTE: This enum /depends/ on starting at value 1
  */
+#ifndef SWIG
 #define ENUM_TERMS_TYPE(_)  \
  _(GNC_TERM_TYPE_DAYS,=1) \
  _(GNC_TERM_TYPE_PROXIMO,)
 
 DEFINE_ENUM(GncBillTermType, ENUM_TERMS_TYPE)
-
-/*typedef enum {
+#else
+typedef enum {
   GNC_TERM_TYPE_DAYS = 1,
   GNC_TERM_TYPE_PROXIMO,
 } GncBillTermType;
-*/
+#endif
+
 /** @name Create/Destroy Functions 
  @{ */
 GncBillTerm * gncBillTermCreate (QofBook *book);
@@ -108,7 +110,6 @@
 
 GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name);
 GList * gncBillTermGetTerms (QofBook *book);
-KvpFrame* gncBillTermGetSlots (GncBillTerm *term);
 
 const char *gncBillTermGetName (GncBillTerm *term);
 const char *gncBillTermGetDescription (GncBillTerm *term);

Modified: gnucash/branches/swigify/src/business/business-core/gncEntry.c
===================================================================
--- gnucash/branches/swigify/src/business/business-core/gncEntry.c	2006-08-13 02:03:32 UTC (rev 14652)
+++ gnucash/branches/swigify/src/business/business-core/gncEntry.c	2006-08-13 02:28:21 UTC (rev 14653)
@@ -1141,7 +1141,7 @@
   return (is_inv ? entry->i_tax_value_rounded : entry->b_tax_value_rounded);
 }
 
-GList * gncEntryReturnTaxValues (GncEntry *entry, gboolean is_inv)
+AccountValueList gncEntryReturnTaxValues (GncEntry *entry, gboolean is_inv)
 {
   if (!entry) return NULL;
   gncEntryRecomputeValues (entry);

Modified: gnucash/branches/swigify/src/business/business-core/gncEntry.h
===================================================================
--- gnucash/branches/swigify/src/business/business-core/gncEntry.h	2006-08-13 02:03:32 UTC (rev 14652)
+++ gnucash/branches/swigify/src/business/business-core/gncEntry.h	2006-08-13 02:28:21 UTC (rev 14653)
@@ -169,7 +169,8 @@
 gnc_numeric gncEntryReturnValue (GncEntry *entry, gboolean is_inv);
 gnc_numeric gncEntryReturnDiscountValue (GncEntry *entry, gboolean is_inv);
 gnc_numeric gncEntryReturnTaxValue (GncEntry *entry, gboolean is_inv);
-GList * gncEntryReturnTaxValues (GncEntry *entry, gboolean is_inv);
+typedef GList * AccountValueList;
+AccountValueList gncEntryReturnTaxValues (GncEntry *entry, gboolean is_inv);
 
 /** Compute the Entry value, tax-value, and discount_value, based on
  * the quantity, price, discount, tax-table, and types.  The value is

Modified: gnucash/branches/swigify/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/branches/swigify/src/business/business-core/gncInvoice.c	2006-08-13 02:03:32 UTC (rev 14652)
+++ gnucash/branches/swigify/src/business/business-core/gncInvoice.c	2006-08-13 02:28:21 UTC (rev 14653)
@@ -94,9 +94,9 @@
   qof_event_gen (&invoice->inst.entity, QOF_EVENT_MODIFY, NULL);
 }
 
-GUID gncInvoiceRetGUID(GncInvoice *x)
-{ 
-    return (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()));
+QofBook * gncInvoiceGetBook(GncInvoice *x) 
+{
+    return qof_instance_get_book(QOF_INSTANCE(x));
 }
 
 /* ================================================================== */
@@ -644,7 +644,7 @@
   return invoice->to_charge_amount;
 }
 
-GList * gncInvoiceGetEntries (GncInvoice *invoice)
+EntryList gncInvoiceGetEntries (GncInvoice *invoice)
 {
   if (!invoice) return NULL;
   return invoice->entries;

Modified: gnucash/branches/swigify/src/business/business-core/gncInvoice.h
===================================================================
--- gnucash/branches/swigify/src/business/business-core/gncInvoice.h	2006-08-13 02:03:32 UTC (rev 14652)
+++ gnucash/branches/swigify/src/business/business-core/gncInvoice.h	2006-08-13 02:28:21 UTC (rev 14653)
@@ -43,6 +43,7 @@
 #include "gncEntry.h"
 #include "gncOwner.h"
 #include "gnc-lot.h"
+#include "qofbook.h"
 
 #define GNC_ID_INVOICE    "gncInvoice"
 #define GNC_IS_INVOICE(obj)  (QOF_CHECK_TYPE((obj), GNC_ID_INVOICE))
@@ -108,7 +109,8 @@
 gnc_numeric gncInvoiceGetTotalSubtotal (GncInvoice *invoice);
 gnc_numeric gncInvoiceGetTotalTax (GncInvoice *invoice);
 
-GList * gncInvoiceGetEntries (GncInvoice *invoice);
+typedef GList * EntryList;
+EntryList gncInvoiceGetEntries (GncInvoice *invoice);
 
 /** Post this invoice to an account.  Returns the new Transaction
  * that is tied to this invoice.   The transaction is set with
@@ -192,12 +194,12 @@
 #define INVOICE_FROM_TXN	"invoice-from-txn"
 
 /** deprecated functions */
-#define gncInvoiceGetBook(x) qof_instance_get_book(QOF_INSTANCE(x))
+//#define gncInvoiceGetBook(x) qof_instance_get_book(QOF_INSTANCE(x))
+QofBook *gncInvoiceGetBook(GncInvoice *x);
 #define gncInvoiceGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
-//#define gncInvoiceRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()))
+#define gncInvoiceRetGUID(x) (x ? *(qof_instance_get_guid(QOF_INSTANCE(x))) : *(guid_null()))
 #define gncInvoiceLookupDirect(G,B) gncInvoiceLookup((B),&(G))
 
-GUID gncInvoiceRetGUID(GncInvoice *x);
 
 #endif /* GNC_INVOICE_H_ */
 /** @} */



More information about the gnucash-changes mailing list