r14954 - gnucash/branches/swig-redo/src/business - Convert all gwrap runtime code into swig code for the business module.

Chris Shoemaker chris at cvs.gnucash.org
Mon Oct 9 19:49:47 EDT 2006


Author: chris
Date: 2006-10-09 19:49:46 -0400 (Mon, 09 Oct 2006)
New Revision: 14954
Trac: http://svn.gnucash.org/trac/changeset/14954

Modified:
   gnucash/branches/swig-redo/src/business/business-gnome/business-options-gnome.c
   gnucash/branches/swig-redo/src/business/business-gnome/dialog-invoice.c
   gnucash/branches/swig-redo/src/business/business-utils/business-options.c
Log:
Convert all gwrap runtime code into swig code for the business module.


Modified: gnucash/branches/swig-redo/src/business/business-gnome/business-options-gnome.c
===================================================================
--- gnucash/branches/swig-redo/src/business/business-gnome/business-options-gnome.c	2006-10-09 23:49:04 UTC (rev 14953)
+++ gnucash/branches/swig-redo/src/business/business-gnome/business-options-gnome.c	2006-10-09 23:49:46 UTC (rev 14954)
@@ -26,7 +26,7 @@
 
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
-#include <g-wrap-wct.h>
+#include "swig-runtime.h"
 #include <libguile.h>
 
 #include "gnc-ui-util.h"
@@ -39,6 +39,8 @@
 #include "business-gnome-utils.h"
 #include "dialog-invoice.h"
 
+#define FUNC_NAME __FUNCTION__
+
 static GtkWidget *
 create_owner_widget (GNCOption *option, GncOwnerType type, GtkWidget *hbox)
 {
@@ -94,12 +96,9 @@
 get_owner_type_from_option (GNCOption *option)
 {
   SCM odata = gnc_option_get_option_data (option);
-  SCM conv_func;
 
-  conv_func = scm_c_eval_string ("gw:enum-<gnc:GncOwnerType>-val->int");
-  odata = scm_call_1 (conv_func, odata);
-
-  return scm_num2long (odata, SCM_ARG1, __FUNCTION__);
+  /* The option data is enum-typed.  It's just the enum value. */
+  return (GncOwnerType) scm_num2int(odata, SCM_ARG1, __FUNCTION__);
 }
 
 
@@ -135,11 +134,11 @@
   GncOwner owner_def;
   GncOwner *owner;
 
-  if (!gw_wcp_p (value))
+  if (!SWIG_IsPointer (value))
     scm_misc_error("business_options:owner_set_value",
-		   "Item is not a gw:wcp.", value);
+		   "SCM is not a wrapped pointer.", value);
 
-  owner = gw_wcp_get_ptr (value);
+  owner = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncOwner"), 1, 0);
 
   /* XXX: should we verify that the owner type is correct? */
   if (!owner) {
@@ -164,7 +163,7 @@
   owner.type = type;
   gnc_owner_get_owner (widget, &owner);
 
-  return gw_wcp_assimilate_ptr (&owner, scm_c_eval_string("<gnc:GncOwner*>"));
+  return SWIG_NewPointerObj(&owner, SWIG_TypeQuery("_p__gncOwner"), 0);
 }
 
 
@@ -203,11 +202,11 @@
   GncOwner owner;
   GncCustomer *customer;
 
-  if (!gw_wcp_p (value))
+  if (!SWIG_IsPointer (value))
     scm_misc_error("business_options:customer_set_value",
-		   "Item is not a gw:wcp.", value);
+		   "SCM is not a wrapped pointer.", value);
 
-  customer = gw_wcp_get_ptr (value);
+  customer = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncCustomer"), 1, 0);
   gncOwnerInitCustomer (&owner, customer);
 
   widget = gnc_option_get_widget (option);
@@ -222,9 +221,8 @@
   GncOwner owner;
 
   gnc_owner_get_owner (widget, &owner);
-
-  return gw_wcp_assimilate_ptr (owner.owner.undefined,
-				scm_c_eval_string("<gnc:GncCustomer*>"));
+  return SWIG_NewPointerObj(owner.owner.undefined,
+                            SWIG_TypeQuery("_p__gncCustomer"), 0);
 }
 
 
@@ -263,11 +261,11 @@
   GncOwner owner;
   GncVendor *vendor;
 
-  if (!gw_wcp_p (value))
+  if (!SWIG_IsPointer (value))
     scm_misc_error("business_options:vendor_set_value",
-		   "Item is not a gw:wcp.", value);
+		   "SCM is not a wrapped pointer.", value);
 
-  vendor = gw_wcp_get_ptr (value);
+  vendor = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncVendor"), 1, 0);
   gncOwnerInitVendor (&owner, vendor);
 
   widget = gnc_option_get_widget (option);
@@ -282,9 +280,8 @@
   GncOwner owner;
 
   gnc_owner_get_owner (widget, &owner);
-
-  return gw_wcp_assimilate_ptr (owner.owner.undefined,
-				scm_c_eval_string("<gnc:GncVendor*>"));
+  return SWIG_NewPointerObj(owner.owner.undefined,
+                            SWIG_TypeQuery("_p__gncVendor"), 0);
 }
 
 /********************************************************************/
@@ -322,11 +319,11 @@
   GncOwner owner;
   GncEmployee *employee;
 
-  if (!gw_wcp_p (value))
+  if (!SWIG_IsPointer (value))
     scm_misc_error("business_options:employee_set_value",
-		   "Item is not a gw:wcp.", value);
+		   "SCM is not a wrapped pointer.", value);
 
-  employee = gw_wcp_get_ptr (value);
+  employee = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncEmployee"), 1, 0);
   gncOwnerInitEmployee (&owner, employee);
 
   widget = gnc_option_get_widget (option);
@@ -342,8 +339,8 @@
 
   gnc_owner_get_owner (widget, &owner);
 
-  return gw_wcp_assimilate_ptr (owner.owner.undefined,
-				scm_c_eval_string("<gnc:GncEmployee*>"));
+  return SWIG_NewPointerObj(owner.owner.undefined,
+                            SWIG_TypeQuery("_p__gncEmployee"), 0);
 }
 
 /********************************************************************/
@@ -396,11 +393,11 @@
 {
   GncInvoice *invoice;
 
-  if (!gw_wcp_p (value))
+  if (!SWIG_IsPointer (value))
     scm_misc_error("business_options:invoice_set_value",
-		   "Item is not a gw:wcp.", value);
+		   "SCM is not a wrapped pointer.", value);
 
-  invoice = gw_wcp_get_ptr (value);
+  invoice = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncInvoice"), 1, 0);
 
   widget = gnc_option_get_widget (option);
   gnc_general_search_set_selected (GNC_GENERAL_SEARCH (widget), invoice);
@@ -414,7 +411,7 @@
   GncInvoice *invoice;
 
   invoice = gnc_general_search_get_selected (GNC_GENERAL_SEARCH (widget));
-  return gw_wcp_assimilate_ptr (invoice, scm_c_eval_string("<gnc:GncInvoice*>"));
+  return SWIG_NewPointerObj(invoice, SWIG_TypeQuery("_p__gncInvoice"), 0);
 }
 
 
@@ -471,11 +468,11 @@
 {
   GncTaxTable *taxtable;
 
-  if (!gw_wcp_p (value))
+  if (!SWIG_IsPointer (value))
     scm_misc_error("business_options:taxtable_set_value",
-		   "Item is not a gw:wcp.", value);
+		   "SCM is not a wrapped pointer.", value);
 
-  taxtable = gw_wcp_get_ptr (value);
+  taxtable = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncTaxTable"), 1, 0);
 
   widget = gnc_option_get_widget (option);
   gnc_ui_optionmenu_set_value (widget, taxtable);
@@ -489,7 +486,7 @@
   GncTaxTable *taxtable;
 
   taxtable = gnc_ui_optionmenu_get_value (widget);
-  return gw_wcp_assimilate_ptr (taxtable, scm_c_eval_string("<gnc:GncTaxTable*>"));
+  return SWIG_NewPointerObj(taxtable, SWIG_TypeQuery("_p__gncTaxTable"), 0);
 }
 
 
@@ -510,6 +507,7 @@
     { NULL }
   };
 
+  SWIG_GetModule(NULL); /* Work-around for SWIG bug. */
   for (i = 0; options[i].option_name; i++)
     gnc_options_ui_register_option (&(options[i]));
 }

Modified: gnucash/branches/swig-redo/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/branches/swig-redo/src/business/business-gnome/dialog-invoice.c	2006-10-09 23:49:04 UTC (rev 14953)
+++ gnucash/branches/swig-redo/src/business/business-gnome/dialog-invoice.c	2006-10-09 23:49:46 UTC (rev 14954)
@@ -27,7 +27,7 @@
 
 #include <gnome.h>
 #include <glib/gi18n.h>
-#include <g-wrap-wct.h>
+#include <g-wrap-wct.h>  // still needed for g-wrapped types
 #include <libguile.h>
 
 #include "gncObject.h"
@@ -555,6 +555,8 @@
   }
 }
 
+#include "swig-runtime.h"
+
 void
 gnc_invoice_window_printCB (GtkWidget *widget, gpointer data)
 {
@@ -569,7 +571,7 @@
   func = scm_c_eval_string ("gnc:invoice-report-create");
   g_return_if_fail (SCM_PROCEDUREP (func));
 
-  arg = gw_wcp_assimilate_ptr (invoice, scm_c_eval_string("<gnc:GncInvoice*>"));
+  arg = SWIG_NewPointerObj(invoice, SWIG_TypeQuery("_p__gncInvoice"), 0);
   args = scm_cons (arg, args);
 
   /* scm_gc_protect_object(func); */
@@ -757,10 +759,7 @@
     args = scm_cons (SCM_BOOL_F, args);
   }
 
-  qtype = scm_c_eval_string("<gnc:GncOwner*>");
-  g_return_if_fail (qtype != SCM_UNDEFINED);
-
-  arg = gw_wcp_assimilate_ptr (owner, qtype);
+  arg = SWIG_NewPointerObj(owner, SWIG_TypeQuery("_p__gncOwner"), 0);
   g_return_if_fail (arg != SCM_UNDEFINED);
   args = scm_cons (arg, args);
 

Modified: gnucash/branches/swig-redo/src/business/business-utils/business-options.c
===================================================================
--- gnucash/branches/swig-redo/src/business/business-utils/business-options.c	2006-10-09 23:49:04 UTC (rev 14953)
+++ gnucash/branches/swig-redo/src/business/business-utils/business-options.c	2006-10-09 23:49:46 UTC (rev 14954)
@@ -25,11 +25,11 @@
 #include "config.h"
 
 #include "business-options.h"
+#include "swig-runtime.h"
 
-#include <g-wrap-wct.h>
+#define FUNC_NAME __FUNCTION__
 
-
-#define LOOKUP_OPTION(fcn) { \
+#define LOOKUP_OPTION(fcn) \
   GNCOption *option; \
   SCM getter; \
   SCM value; \
@@ -46,13 +46,9 @@
   value = scm_call_0 (getter); \
   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); \
-}
-	
+  SWIG_GetModule(NULL); /* Work-around for SWIG bug. */       \
+  if (!SWIG_IsPointer(value))             \
+    scm_misc_error(fcn, "SCM is not a wrapped pointer.", value)
 
 GncTaxTable*
 gnc_option_db_lookup_taxtable_option(GNCOptionDB *odb,
@@ -61,6 +57,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 +67,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 +77,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 +87,5 @@
 				   GncVendor * default_value)
 {
   LOOKUP_OPTION("gnc_option_db_lookup_vendor_option");
+  return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncVendor"), 1, 0);
 }



More information about the gnucash-changes mailing list