r14962 - gnucash/branches/swig-redo/src/report - Convert the report-system module form gwrap to swig. All at once:

Chris Shoemaker chris at cvs.gnucash.org
Mon Oct 9 19:56:09 EDT 2006


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

Added:
   gnucash/branches/swig-redo/src/report/report-system/report-system.i
Modified:
   gnucash/branches/swig-redo/src/report/report-system/Makefile.am
   gnucash/branches/swig-redo/src/report/report-system/gnc-report.c
   gnucash/branches/swig-redo/src/report/report-system/gnc-report.h
   gnucash/branches/swig-redo/src/report/report-system/gncmod-report-system.c
   gnucash/branches/swig-redo/src/report/report-system/report-system.scm
   gnucash/branches/swig-redo/src/report/report-system/report.scm
   gnucash/branches/swig-redo/src/report/utility-reports/view-column.scm
   gnucash/branches/swig-redo/src/report/utility-reports/welcome-to-gnucash.scm
Log:
Convert the report-system module form gwrap to swig.  All at once:
  Add the interface definiton.
  Convert the runtime code from gwrap to swig.
  Rename wrapped function calls to their swig-names.
  Use '() instead of #f for the empty object.
  Use gint instead of int in gnc-report.[ch]



Modified: gnucash/branches/swig-redo/src/report/report-system/Makefile.am
===================================================================
--- gnucash/branches/swig-redo/src/report/report-system/Makefile.am	2006-10-09 23:55:31 UTC (rev 14961)
+++ gnucash/branches/swig-redo/src/report/report-system/Makefile.am	2006-10-09 23:56:08 UTC (rev 14962)
@@ -1,8 +1,9 @@
 SUBDIRS = . test
 
-pkglib_LTLIBRARIES = libgncmod-report-system.la libgw-report-system.la
+pkglib_LTLIBRARIES = libgncmod-report-system.la
 
 libgncmod_report_system_la_SOURCES = \
+  swig-report-system.c \
   gncmod-report-system.c \
   gnc-report.c
 
@@ -16,6 +17,8 @@
   ${GUILE_LIBS} \
   ${GLIB_LIBS}
 
+swig-report-system.c: report-system.i ${gncinclude_HEADERS}
+	swig -guile $(SWIG_ARGS) -Linkage module -o $@ $<
 
 AM_CFLAGS = \
   -I${top_srcdir}/src \
@@ -48,19 +51,16 @@
 
 if GNUCASH_SEPARATE_BUILDDIR
 #For executing test cases
-# for compiling
-SCM_FILE_LINKS = gw-report-system-spec.scm
 # for running
-SCM_FILE_LINKS += \
+SCM_FILE_LINKS = \
   ${gncscmmod_DATA} \
   ${gncscm_DATA}
 endif
 
 .scm-links:
-	rm -f gnucash report g-wrapped
+	rm -f gnucash report
 	$(LN_S) -f . gnucash
 	$(LN_S) -f . report 
-	$(LN_S) -f . g-wrapped
 if GNUCASH_SEPARATE_BUILDDIR
 	for X in ${SCM_FILE_LINKS} ; do \
 	  $(LN_S) -f ${srcdir}/$$X . ; \
@@ -68,30 +68,9 @@
 endif
 	touch .scm-links
 
-nodist_libgw_report_system_la_SOURCES = gw-report-system.c
-libgw_report_system_la_LIBADD = \
-  libgncmod-report-system.la \
-  ${G_WRAP_LINK_ARGS}
+noinst_DATA = .scm-links
 
-gwmoddir = ${GNC_GWRAP_LIBDIR}
-gwmod_DATA = gw-report-system-spec.scm
-nodist_gwmod_DATA = gw-report-system.scm
+EXTRA_DIST = ${gncscmmod_DATA} ${gncscm_DATA}
 
-noinst_DATA = .scm-links gw-report-system.h
-
-EXTRA_DIST = ${gncscmmod_DATA} ${gncscm_DATA} ${gwmod_DATA}
-
-gw-report-system.scm gw-report-system.c gw-report-system.h: \
-  .scm-links gw-report-system-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)) \
-	  (set! %load-path (cons \"${top_builddir}/src/app-utils\" %load-path)) \
-	  (set! %load-path (cons \"${top_builddir}/src/gnome-utils\" %load-path)) \
-	  (primitive-load \"./gw-report-system-spec.scm\") \
-	  (gw:generate-wrapset \"gw-report-system\")"
-
-BUILT_SOURCES = gw-report-system.scm gw-report-system.c gw-report-system.h
-CLEANFILES = $(BUILT_SOURCES) gnucash g-wrapped report .scm-links \
-	${SCM_FILE_LINKS} gw-report-system.html
+BUILT_SOURCES = swig-report-system.c
+CLEANFILES = $(BUILT_SOURCES) gnucash report .scm-links ${SCM_FILE_LINKS}

Modified: gnucash/branches/swig-redo/src/report/report-system/gnc-report.c
===================================================================
--- gnucash/branches/swig-redo/src/report/report-system/gnc-report.c	2006-10-09 23:55:31 UTC (rev 14961)
+++ gnucash/branches/swig-redo/src/report/report-system/gnc-report.c	2006-10-09 23:56:08 UTC (rev 14962)
@@ -34,7 +34,7 @@
 
 /* Fow now, this is global, like it was in guile.  It _should_ be per-book. */
 static GHashTable *reports = NULL;
-static int report_next_serial_id = 0;
+static gint report_next_serial_id = 0;
 
 static void
 gnc_report_init_table(void)
@@ -67,7 +67,7 @@
     return report;
 }
 
-int gnc_report_add(SCM report)
+gint gnc_report_add(SCM report)
 {
     SCM get_id = scm_c_eval_string("gnc:report-id");
     SCM value;
@@ -133,7 +133,7 @@
 }
 
 gboolean
-gnc_run_report (int report_id, char ** data)
+gnc_run_report (gint report_id, char ** data)
 {
   const gchar *free_data;
   SCM scm_text;
@@ -157,7 +157,7 @@
 gboolean
 gnc_run_report_id_string (const char * id_string, char **data)
 {
-  int report_id;
+  gint report_id;
 
   g_return_val_if_fail (id_string != NULL, FALSE);
   g_return_val_if_fail (data != NULL, FALSE);

Modified: gnucash/branches/swig-redo/src/report/report-system/gnc-report.h
===================================================================
--- gnucash/branches/swig-redo/src/report/report-system/gnc-report.h	2006-10-09 23:55:31 UTC (rev 14961)
+++ gnucash/branches/swig-redo/src/report/report-system/gnc-report.h	2006-10-09 23:56:08 UTC (rev 14962)
@@ -28,7 +28,7 @@
 #include <glib.h>
 #include <libguile.h>
 
-gboolean gnc_run_report (int report_id, char ** data);
+gboolean gnc_run_report (gint report_id, char ** data);
 gboolean gnc_run_report_id_string (const char * id_string, char **data);
 
 /**
@@ -40,7 +40,7 @@
 
 SCM gnc_report_find(gint id);
 void gnc_report_remove_by_id(gint id);
-int gnc_report_add(SCM report);
+gint gnc_report_add(SCM report);
 
 void gnc_reports_flush_global(void);
 GHashTable *gnc_reports_get_global(void);

Modified: gnucash/branches/swig-redo/src/report/report-system/gncmod-report-system.c
===================================================================
--- gnucash/branches/swig-redo/src/report/report-system/gncmod-report-system.c	2006-10-09 23:55:31 UTC (rev 14961)
+++ gnucash/branches/swig-redo/src/report/report-system/gncmod-report-system.c	2006-10-09 23:56:08 UTC (rev 14962)
@@ -38,13 +38,7 @@
   return g_strdup("Core components of GnuCash report generation system");
 }
 
-static void
-lmod(char * mn) 
-{
-  char * form = g_strdup_printf("(use-modules %s)\n", mn);
-  scm_c_eval_string(form);
-  g_free(form);
-}
+extern SCM scm_init_sw_report_system_module(void);
 
 int
 libgncmod_report_system_LTX_gnc_module_init(int refcount) {
@@ -56,8 +50,9 @@
   if(!gnc_module_load("gnucash/app-utils", 0)) {
     return FALSE;
   }
+  scm_init_sw_report_system_module();
   
-  lmod("(gnucash report report-system)");
+  scm_c_eval_string("(use-modules (gnucash report report-system))");
 
   /* if this is the first time the module's being loaded, initialize
    * the relative date system */

Added: gnucash/branches/swig-redo/src/report/report-system/report-system.i
===================================================================
--- gnucash/branches/swig-redo/src/report/report-system/report-system.i	2006-10-09 23:55:31 UTC (rev 14961)
+++ gnucash/branches/swig-redo/src/report/report-system/report-system.i	2006-10-09 23:56:08 UTC (rev 14962)
@@ -0,0 +1,11 @@
+%module sw_report_system
+%{
+/* Includes the header in the wrapper code */
+#include <config.h>
+#include <gnc-report.h>
+%}
+
+typedef int gint;
+
+SCM gnc_report_find(gint id);
+gint gnc_report_add(SCM report);

Modified: gnucash/branches/swig-redo/src/report/report-system/report-system.scm
===================================================================
--- gnucash/branches/swig-redo/src/report/report-system/report-system.scm	2006-10-09 23:55:31 UTC (rev 14961)
+++ gnucash/branches/swig-redo/src/report/report-system/report-system.scm	2006-10-09 23:56:08 UTC (rev 14962)
@@ -13,8 +13,6 @@
 (use-modules (srfi srfi-19))
 (use-modules (gnucash gnc-module))
 
-(use-modules (g-wrap gw-glib))
-
 (require 'hash-table)
 
 (gnc:module-load "gnucash/engine" 0)

Modified: gnucash/branches/swig-redo/src/report/report-system/report.scm
===================================================================
--- gnucash/branches/swig-redo/src/report/report-system/report.scm	2006-10-09 23:55:31 UTC (rev 14961)
+++ gnucash/branches/swig-redo/src/report/report-system/report.scm	2006-10-09 23:56:08 UTC (rev 14962)
@@ -21,7 +21,7 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (use-modules (gnucash main))
-(use-modules (g-wrapped gw-report-system)) 
+(use-modules (sw_report_system))
 
 ;; This hash should contain all the reports available and will be used
 ;; to generate the reports menu whenever a new window opens and to
@@ -99,9 +99,9 @@
 			 (gnc:report-template-name report-rec) report-rec)
 	      (begin
 		;; FIXME: We should pass the top-level window
-		;; instead of the #f to gnc:error-dialog, but I
+		;; instead of the '() to gnc:error-dialog, but I
 		;; have no idea where to get it from.
-		(gnc:error-dialog #f (string-append (_ "A custom report with this name already exists. Either rename the report to store it with a different name, or edit your saved-reports file and delete the section with the following name: ") name ))
+		(gnc:error-dialog '() (string-append (_ "A custom report with this name already exists. Either rename the report to store it with a different name, or edit your saved-reports file and delete the section with the following name: ") name ))
 		)))
         (gnc:warn "gnc:define-report: bad report"))))
 
@@ -266,7 +266,7 @@
                (cb r))))
        options))
 
-    (gnc:report-set-id! r (gnc:report-add r))
+    (gnc:report-set-id! r (gnc-report-add r))
     (gnc:report-id r))
   )
 
@@ -274,7 +274,7 @@
 (define (gnc:restore-report id template-name options)
   (let ((r ((record-constructor <report>)
             template-name id options #t #t #f #f)))
-    (gnc:report-add r))
+    (gnc-report-add r))
   )
 
 
@@ -433,7 +433,7 @@
 ;; looks up the report by id and renders it with gnc:report-render-html
 ;; marks the cursor busy during rendering; returns the html
 (define (gnc:report-run id)
-  (let ((report (gnc:find-report id))
+  (let ((report (gnc-report-find id))
 	(start-time (gettimeofday))
 	(html #f))
     (gnc:set-busy-cursor #f #t)

Modified: gnucash/branches/swig-redo/src/report/utility-reports/view-column.scm
===================================================================
--- gnucash/branches/swig-redo/src/report/utility-reports/view-column.scm	2006-10-09 23:55:31 UTC (rev 14961)
+++ gnucash/branches/swig-redo/src/report/utility-reports/view-column.scm	2006-10-09 23:56:08 UTC (rev 14962)
@@ -30,7 +30,7 @@
 (use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
 (use-modules (ice-9 slib))
 (use-modules (gnucash gnc-module))
-(use-modules (g-wrapped gw-report-system))
+(use-modules (sw_report_system))
 
 (require 'printf)
 
@@ -96,7 +96,7 @@
 	       (begin 
 		 (set! callback 
 		       (make-child-options-callback
-			report (gnc:find-report child)))
+			report (gnc-report-find child)))
 		 (set! report-info 
 		       (list child rowspan colspan callback))))
 	   (set! new-reports (cons report-info new-reports))))
@@ -115,7 +115,7 @@
        ;; hash is an attempt to compute how many columnc are
        ;; actually used in a row; items with non-1 rowspans will take
        ;; up cells in the row without actually being in the row.
-       (let* ((subreport (gnc:find-report (car report-info)))
+       (let* ((subreport (gnc-report-find (car report-info)))
 	      (colspan (cadr report-info))
 	      (rowspan (caddr report-info))
 	      (opt-callback (cadddr report-info))
@@ -217,7 +217,7 @@
 	   (gnc:lookup-option options "__general" "report-list"))))
     (for-each 
      (lambda (child)
-       (gnc:report-set-dirty?! (gnc:find-report (car child)) #t))
+       (gnc:report-set-dirty?! (gnc-report-find (car child)) #t))
      reports)))
 
 (define (cleanup-options report)

Modified: gnucash/branches/swig-redo/src/report/utility-reports/welcome-to-gnucash.scm
===================================================================
--- gnucash/branches/swig-redo/src/report/utility-reports/welcome-to-gnucash.scm	2006-10-09 23:55:31 UTC (rev 14961)
+++ gnucash/branches/swig-redo/src/report/utility-reports/welcome-to-gnucash.scm	2006-10-09 23:56:08 UTC (rev 14962)
@@ -25,7 +25,7 @@
 
 (use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
 (use-modules (gnucash gnc-module))
-(use-modules (g-wrapped gw-report-system))
+(use-modules (sw_report_system))
 
 (gnc:module-load "gnucash/report/report-system" 0)
 
@@ -42,16 +42,16 @@
       (gnc:option-set-value 
        (gnc:lookup-option options section name) value))
 
-    (set! options (gnc:report-options (gnc:find-report view)))
+    (set! options (gnc:report-options (gnc-report-find view)))
     (set-option! "General" "Report name" (_ "Welcome to GnuCash"))
     (set-option! "General" "Number of columns" 2)
 
     ;; mark the reports as needing to be saved 
-    (gnc:report-set-needs-save?! (gnc:find-report sub-welcome) #t)
-    (gnc:report-set-needs-save?! (gnc:find-report sub-accounts) #t)
-    (gnc:report-set-needs-save?! (gnc:find-report sub-expense-pie) #t)
-    (gnc:report-set-needs-save?! (gnc:find-report sub-income-pie) #t)
-    (gnc:report-set-needs-save?! (gnc:find-report sub-bar) #t)
+    (gnc:report-set-needs-save?! (gnc-report-find sub-welcome) #t)
+    (gnc:report-set-needs-save?! (gnc-report-find sub-accounts) #t)
+    (gnc:report-set-needs-save?! (gnc-report-find sub-expense-pie) #t)
+    (gnc:report-set-needs-save?! (gnc-report-find sub-income-pie) #t)
+    (gnc:report-set-needs-save?! (gnc-report-find sub-bar) #t)
 
     (set-option! "__general" "report-list" 
                  (list (list sub-welcome 1 1 #f)
@@ -60,13 +60,13 @@
                        (list sub-income-pie 1 1 #f)
                        (list sub-bar 2 1 #f)))
     
-    (set! options (gnc:report-options (gnc:find-report sub-expense-pie)))
+    (set! options (gnc:report-options (gnc-report-find sub-expense-pie)))
     (set-option! "Display" "Plot Width" 400)
     
-    (set! options (gnc:report-options (gnc:find-report sub-income-pie)))
+    (set! options (gnc:report-options (gnc-report-find sub-income-pie)))
     (set-option! "Display" "Plot Width" 400)
     
-    (set! options (gnc:report-options (gnc:find-report sub-bar)))
+    (set! options (gnc:report-options (gnc-report-find sub-bar)))
     (set-option! "Display" "Plot Width" 800)
 
     view))



More information about the gnucash-changes mailing list