r14652 - gnucash/branches/swigify/src/engine - Add SWIG wrappers to src/engine, leaving them alongside the g-wrap wrappers.

Chris Shoemaker chris at cvs.gnucash.org
Sat Aug 12 22:03:33 EDT 2006


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

Added:
   gnucash/branches/swigify/src/engine/engine.i
   gnucash/branches/swigify/src/engine/kvp.i
Modified:
   gnucash/branches/swigify/src/engine/Makefile.am
   gnucash/branches/swigify/src/engine/engine.scm
   gnucash/branches/swigify/src/engine/gncmod-engine.c
Log:
   Add SWIG wrappers to src/engine, leaving them alongside the g-wrap wrappers.


Modified: gnucash/branches/swigify/src/engine/Makefile.am
===================================================================
--- gnucash/branches/swigify/src/engine/Makefile.am	2006-08-13 01:59:49 UTC (rev 14651)
+++ gnucash/branches/swigify/src/engine/Makefile.am	2006-08-13 02:03:32 UTC (rev 14652)
@@ -41,6 +41,11 @@
   gnc-session.c \
   gnc-session-scm.c \
   gncmod-engine.c \
+  swig-engine.c \
+  swig-kvp.c \
+  kvp-scm.c \
+  engine-helpers.c \
+  glib-helpers.c  \
   policy.c
 
 EXTRA_libgncmod_engine_la_SOURCES = iso-4217-currencies.c
@@ -112,6 +117,9 @@
   ${GNUCASH_ENGINE_BASE_LIBS} \
   ${top_builddir}/lib/libc/libc-missing.la
 
+swig-kvp.c: kvp.i
+	swig -guile $(SWIG_ARGS) -Linkage module -o $@ $<
+
 libgw_kvp_la_SOURCES = kvp-scm.c
 nodist_libgw_kvp_la_SOURCES = gw-kvp.c
 libgw_kvp_la_LDFLAGS = \
@@ -149,6 +157,9 @@
   gw-engine.scm \
   gw-kvp.scm
 
+swig-engine.c: engine.i
+	swig -guile $(SWIG_ARGS) -Linkage module -o $@ $<
+
 EXTRA_DIST = \
   README.query-api \
   design.txt \

Added: gnucash/branches/swigify/src/engine/engine.i
===================================================================
--- gnucash/branches/swigify/src/engine/engine.i	2006-08-13 01:59:49 UTC (rev 14651)
+++ gnucash/branches/swigify/src/engine/engine.i	2006-08-13 02:03:32 UTC (rev 14652)
@@ -0,0 +1,67 @@
+%module sw_engine
+%{
+/* Includes the header in the wrapper code */
+#include <config.h>
+#include <glib.h>
+#include <qof.h>
+#include <Group.h>
+#include <Query.h>
+#include <gnc-budget.h>
+#include <gnc-commodity.h>
+#include <gnc-engine.h>
+#include <gnc-filepath-utils.h>
+#include <gnc-pricedb.h>
+#include <gnc-lot.h>
+#include <gnc-session-scm.h>
+#include <gnc-hooks-scm.h>
+#include <engine-helpers.h>
+#include <SX-book.h>
+
+%}
+
+%typemap(in) gboolean {
+  $1 = SCM_NFALSEP($input) ? TRUE : FALSE;
+}
+
+%typemap(out) gboolean {
+  $result = $1 ? SCM_BOOL_T : SCM_BOOL_F;
+}
+
+%typemap(in) Timespec {
+  $1 = gnc_timepair2timespec($input);
+}
+
+%typemap(out) Timespec {
+  $result = gnc_timespec2timepair($1);
+}
+
+%typemap(in) GUID {
+  $1 = gnc_scm2guid($input);
+}
+
+%typemap(out) GUID {
+  $result = gnc_guid2scm($1);
+}
+
+%typemap(in) gnc_numeric {
+  $1 = gnc_scm_to_numeric($input);
+}
+
+%typemap(out) gnc_numeric {
+  $result = gnc_numeric_to_scm($1);
+}
+
+/* Parse the header file to generate wrappers */
+%include <Group.h>
+%include <Query.h>
+%include <gnc-budget.h>
+%include <gnc-commodity.h>
+%include <gnc-engine.h>
+%include <gnc-filepath-utils.h>
+%include <gnc-pricedb.h>
+%include <gnc-lot.h>
+%include <gnc-session-scm.h>
+%include <gnc-hooks-scm.h>
+%include <engine-helpers.h>
+%include <SX-book.h>
+

Modified: gnucash/branches/swigify/src/engine/engine.scm
===================================================================
--- gnucash/branches/swigify/src/engine/engine.scm	2006-08-13 01:59:49 UTC (rev 14651)
+++ gnucash/branches/swigify/src/engine/engine.scm	2006-08-13 02:03:32 UTC (rev 14652)
@@ -1,7 +1,9 @@
 (define-module (gnucash engine))
 
+(load-extension "libgncmod-engine" "scm_init_sw_engine_module")
+(use-modules (sw_engine))
+
 (use-modules (g-wrap gw-wct))
-
 (use-modules (g-wrapped gw-engine))
 
 (export GNC-RND-FLOOR)

Modified: gnucash/branches/swigify/src/engine/gncmod-engine.c
===================================================================
--- gnucash/branches/swigify/src/engine/gncmod-engine.c	2006-08-13 01:59:49 UTC (rev 14651)
+++ gnucash/branches/swigify/src/engine/gncmod-engine.c	2006-08-13 02:03:32 UTC (rev 14652)
@@ -41,6 +41,8 @@
   return g_strdup("The GnuCash accounting engine");
 }
 
+extern SCM scm_init_sw_kvp_module(void);
+
 int
 libgncmod_engine_LTX_gnc_module_init(int refcount) 
 {
@@ -54,6 +56,8 @@
 
   scm_c_eval_string("(use-modules (g-wrap gw-glib))");
 
+  scm_init_sw_kvp_module();
+  scm_c_eval_string("(use-modules (sw_kvp))");
   scm_c_eval_string("(use-modules (g-wrapped gw-kvp))");
   scm_c_eval_string("(use-modules (g-wrapped gw-engine))");
 

Added: gnucash/branches/swigify/src/engine/kvp.i
===================================================================
--- gnucash/branches/swigify/src/engine/kvp.i	2006-08-13 01:59:49 UTC (rev 14651)
+++ gnucash/branches/swigify/src/engine/kvp.i	2006-08-13 02:03:32 UTC (rev 14652)
@@ -0,0 +1,47 @@
+%module sw_kvp
+%{
+/* Includes the header in the wrapper code */
+#include <qof.h>
+#include <kvp-scm.h>
+//#include <Transaction.h>
+#include "glib-helpers.h"
+%}
+
+/* Convert from Guile --> C */
+%typemap(in) GUID {
+    $1 = gnc_scm2guid($input);
+}
+
+/* Convert from C --> Guile */
+%typemap(out) GUID {
+    $result = gnc_guid2scm($1);
+}
+
+
+/* Parse the header file to generate wrappers */
+//%include <kvp-scm.h>
+//%include <Transaction.h>
+
+void gnc_kvp_frame_delete_at_path(KvpFrame *frame, GSList *key_path);
+
+void kvp_frame_set_slot_path_gslist(
+   KvpFrame *frame, const KvpValue *new_value, GSList *key_path);
+
+%typemap(in) GSList *key_path {
+  $1 = gnc_scm_to_gslist_string($input);
+}
+
+%typemap(out) KvpValue * {
+  $result = gnc_kvp_value_ptr_to_scm($1);
+}
+
+KvpValue * kvp_frame_get_slot_path_gslist (KvpFrame *frame, GSList *key_path);
+
+%typemap(in) GSList *key_path ""
+%typemap(out) KvpValue * ""
+
+%inline %{
+KvpFrame * gnc_book_get_slots(QofBook *book) {
+   qof_instance_get_slots(QOF_INSTANCE(book));
+}
+%}
\ No newline at end of file



More information about the gnucash-changes mailing list