r14966 - gnucash/branches/swig-redo/src/app-utils - Begin to convert the app-utils module from gwrap to swig.

Chris Shoemaker chris at cvs.gnucash.org
Mon Oct 9 19:59:12 EDT 2006


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

Added:
   gnucash/branches/swig-redo/src/app-utils/app-utils.i
Modified:
   gnucash/branches/swig-redo/src/app-utils/Makefile.am
   gnucash/branches/swig-redo/src/app-utils/gncmod-app-utils.c
Log:
Begin to convert the app-utils module from gwrap to swig.
  Add the interface definition.
  Build and load the swig module.



Modified: gnucash/branches/swig-redo/src/app-utils/Makefile.am
===================================================================
--- gnucash/branches/swig-redo/src/app-utils/Makefile.am	2006-10-09 23:58:40 UTC (rev 14965)
+++ gnucash/branches/swig-redo/src/app-utils/Makefile.am	2006-10-09 23:59:11 UTC (rev 14966)
@@ -1,7 +1,7 @@
 SUBDIRS = . test
 PWD := $(shell pwd)
 
-pkglib_LTLIBRARIES = libgncmod-app-utils.la libgw-app-utils.la
+pkglib_LTLIBRARIES = libgncmod-app-utils.la
 
 AM_CFLAGS = \
   -I${top_srcdir}/src \
@@ -17,6 +17,7 @@
   ${GTK_CFLAGS}
 
 libgncmod_app_utils_la_SOURCES = \
+  swig-app-utils.c \
   file-utils.c \
   gfec.c \
   gnc-account-merge.c \
@@ -77,18 +78,10 @@
   ${QOF_LIBS} \
   ${GLIB_LIBS}
 
-libgw_app_utils_la_LIBADD = \
-  libgncmod-app-utils.la \
-  ${top_builddir}/src/engine/libgncmod-engine.la \
-  ${top_builddir}/src/engine/libgw-engine.la \
-  ${top_builddir}/src/core-utils/libcore-utils.la \
-  ${G_WRAP_LINK_ARGS} \
-  ${GUILE_LIBS} \
-  ${QOF_LIBS} \
-  ${GLIB_LIBS}
+swig-app-utils.c: app-utils.i ${gncinclude_HEADERS}
+	swig -guile $(SWIG_ARGS) -Linkage module \
+	-I${top_srcdir}/src/engine -I${top_srcdir}/lib/libqof/qof -o $@ $<
 
-nodist_libgw_app_utils_la_SOURCES = gw-app-utils.c
-
 gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash
 gncmod_DATA = app-utils.scm 
 
@@ -103,30 +96,22 @@
   prefs.scm \
   simple-obj.scm
 
-gwmoddir = ${GNC_GWRAP_LIBDIR}
-gwmod_DATA = gw-app-utils-spec.scm
-nodist_gwmod_DATA = gw-app-utils.scm
-
 noinst_DATA = .scm-links
 
 EXTRA_DIST = \
   ${gncmod_DATA} \
-  ${gncscm_DATA} \
-  ${gwmod_DATA}
+  ${gncscm_DATA}
 
 if GNUCASH_SEPARATE_BUILDDIR
-#For compiling
-SCM_FILE_LINKS = gw-app-utils-spec.scm
 #For executing test cases
-SCM_FILE_LINKS += \
+SCM_FILE_LINKS = \
   ${gncmod_DATA} \
   ${gncscm_DATA}
 endif
 
 .scm-links: 
-	rm -f gnucash g-wrapped
+	rm -f gnucash
 	$(LN_S) -f . gnucash 
-	$(LN_S) -f . g-wrapped 
 if GNUCASH_SEPARATE_BUILDDIR
 	for X in ${SCM_FILE_LINKS} ; do \
 	  $(LN_S) -f ${srcdir}/$$X . ; \
@@ -134,15 +119,5 @@
 endif
 	touch .scm-links
 
-gw-app-utils.scm gw-app-utils.c gw-app-utils.h: \
-  .scm-links gw-app-utils-spec.scm ${top_builddir}/config.status
-	FLAVOR=gnome $(GUILE) -c \
-	 "(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
-	  (set! %load-path (cons \"${PWD}\" %load-path)) \
-	  (set! %load-path (cons \"${top_builddir}/src/engine\" %load-path)) \
-	  (primitive-load \"./gw-app-utils-spec.scm\") \
-	  (gw:generate-wrapset \"gw-app-utils\")"
-
-BUILT_SOURCES = gw-app-utils.scm gw-app-utils.c gw-app-utils.h
-CLEANFILES = $(BUILT_SOURCES) ${SCM_FILE_LINKS} gnucash g-wrapped \
-	.scm-links gw-app-utils.html
+BUILT_SOURCES = swig-app-utils.c
+CLEANFILES = $(BUILT_SOURCES) ${SCM_FILE_LINKS} gnucash .scm-links

Added: gnucash/branches/swig-redo/src/app-utils/app-utils.i
===================================================================
--- gnucash/branches/swig-redo/src/app-utils/app-utils.i	2006-10-09 23:58:40 UTC (rev 14965)
+++ gnucash/branches/swig-redo/src/app-utils/app-utils.i	2006-10-09 23:59:11 UTC (rev 14966)
@@ -0,0 +1,123 @@
+%module sw_app_utils
+%{
+/* Includes the header in the wrapper code */
+#include <config.h>
+#include <option-util.h>
+#include <gnc-euro.h>
+#include <gnc-exp-parser.h>
+#include <gnc-ui-util.h>
+#include <gnc-gettext-util.h>
+#include <gnc-helpers.h>
+#include <gnc-accounting-period.h>
+#include <gnc-session.h>
+#include <gnc-component-manager.h>
+
+#include <g-wrap-wct.h> //Temporary. Adds no link dep?!?
+#include "engine-helpers.h"
+%}
+
+%typemap(in) GNCPrintAmountInfo "$1 = gnc_scm2printinfo($input);"
+%typemap(out) GNCPrintAmountInfo "$result = gnc_printinfo2scm($1);"
+
+%typemap(out) GncCommodityList {
+  SCM list = SCM_EOL;
+  GList *node;
+
+  for (node = $1; node; node = node->next)
+    list = scm_cons(gnc_quoteinfo2scm(node->data), list);
+
+  $result = scm_reverse(list);
+}
+
+// Temporary SWIG<->G-wrap converters for engine types
+%typemap(in) QofBook * "$1 = (QofBook *)gw_wcp_get_ptr($input);"
+%typemap(out) QofBook * {
+  $result = gw_wcp_assimilate_ptr($1, scm_c_eval_string("<gnc:Book*>"));
+}
+%typemap(in) gboolean "$1 = SCM_NFALSEP($input) ? TRUE : FALSE;"
+%typemap(out) gboolean "$result = $1 ? SCM_BOOL_T : SCM_BOOL_F;"
+
+%typemap(in) gnc_numeric "$1 = gnc_scm_to_numeric($input);"
+%typemap(out) gnc_numeric "$result = gnc_numeric_to_scm($1);"
+%typemap(in) gnc_commodity * "$1 = (gnc_commodity *)gw_wcp_get_ptr($input);"
+%typemap(out) gnc_commodity * {
+  $result = gw_wcp_assimilate_ptr($1, scm_c_eval_string("<gnc:commodity*>"));
+}
+%typemap(in) Account * "$1 = (Account *)gw_wcp_get_ptr($input);"
+%typemap(out) Account * {
+  $result = gw_wcp_assimilate_ptr($1, scm_c_eval_string("<gnc:Account*>"));
+}
+%typemap(in) AccountGroup * "$1 = (AccountGroup *)gw_wcp_get_ptr($input);"
+%typemap(out) AccountGroup * {
+  $result = gw_wcp_assimilate_ptr($1, scm_c_eval_string("<gnc:AccountGroup*>"));
+}
+%typemap(in) gnc_commodity_table * {
+  $1 = (gnc_commodity_table *)gw_wcp_get_ptr($input);
+}
+%typemap(out) gnc_commodity_table * {
+  $result = gw_wcp_assimilate_ptr($1,
+       scm_c_eval_string("<gnc:commodity-table*>"));
+}
+%typemap(in) gnc_commodity * {
+  $1 = (gnc_commodity *)gw_wcp_get_ptr($input);
+}
+%typemap(out) gnc_commodity * {
+  $result = gw_wcp_assimilate_ptr($1,
+       scm_c_eval_string("<gnc:commodity*>"));
+}
+
+// End of temporary typemaps.
+
+typedef void (*GNCOptionChangeCallback) (gpointer user_data);
+typedef int GNCOptionDBHandle;
+
+QofBook * gnc_get_current_book (void);
+AccountGroup * gnc_get_current_group (void);
+
+char * gnc_gettext_helper(const char *string);
+
+GNCOptionDB * gnc_option_db_new(SCM guile_options);
+void gnc_option_db_destroy(GNCOptionDB *odb);
+
+void gnc_option_db_set_option_selectable_by_name(SCM guile_option,
+      const char *section, const char *name, gboolean selectable);
+
+%inline %{
+typedef GList GncCommodityList;
+
+GncCommodityList *
+gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table);
+%}
+
+gnc_commodity * gnc_default_currency (void);
+gnc_commodity * gnc_default_report_currency (void);
+
+void gncp_option_invoke_callback(GNCOptionChangeCallback callback, void *data);
+void gnc_option_db_register_option(GNCOptionDBHandle handle,
+        SCM guile_option);
+
+const char * gnc_locale_default_iso_currency_code (void);
+
+char * gnc_account_get_full_name (const Account *account);
+
+GNCPrintAmountInfo gnc_default_print_info (gboolean use_symbol);
+GNCPrintAmountInfo gnc_account_print_info (const Account *account,
+        gboolean use_symbol);
+GNCPrintAmountInfo gnc_commodity_print_info (const gnc_commodity *commodity,
+        gboolean use_symbol);
+GNCPrintAmountInfo gnc_share_print_info_places (int decplaces);
+const char * xaccPrintAmount (gnc_numeric val, GNCPrintAmountInfo info);
+
+gboolean gnc_reverse_balance (const Account *account);
+
+gboolean gnc_is_euro_currency(const gnc_commodity * currency);
+gnc_numeric gnc_convert_to_euro(const gnc_commodity * currency,
+        gnc_numeric value);
+gnc_numeric gnc_convert_from_euro(const gnc_commodity * currency,
+        gnc_numeric value);
+
+
+typedef int time_t;
+time_t gnc_accounting_period_fiscal_start(void);
+time_t gnc_accounting_period_fiscal_end(void);
+

Modified: gnucash/branches/swig-redo/src/app-utils/gncmod-app-utils.c
===================================================================
--- gnucash/branches/swig-redo/src/app-utils/gncmod-app-utils.c	2006-10-09 23:58:40 UTC (rev 14965)
+++ gnucash/branches/swig-redo/src/app-utils/gncmod-app-utils.c	2006-10-09 23:59:11 UTC (rev 14966)
@@ -57,6 +57,9 @@
     gnc_hook_run(HOOK_SAVE_OPTIONS, NULL);
 }
 
+
+extern SCM scm_init_sw_app_utils_module(void);
+
 int
 libgncmod_app_utils_LTX_gnc_module_init(int refcount)
 {
@@ -70,9 +73,10 @@
     return FALSE;
   }
 
-  /* publish g-wrapped bindings */
+  scm_init_sw_app_utils_module();
+  /* publish swig bindings */
   /* load the scheme code */
-  lmod("(g-wrapped gw-app-utils)");
+  lmod("(sw_app_utils)");
   lmod("(gnucash app-utils)");
 
   if (refcount == 0) {



More information about the gnucash-changes mailing list