r21600 - gnucash/trunk/src - [Python] Export core-utils SWIG wrappers to Python.

John Ralls jralls at code.gnucash.org
Sun Nov 20 13:27:00 EST 2011


Author: jralls
Date: 2011-11-20 13:27:00 -0500 (Sun, 20 Nov 2011)
New Revision: 21600
Trac: http://svn.gnucash.org/trac/changeset/21600

Modified:
   gnucash/trunk/src/base-typemaps.i
   gnucash/trunk/src/core-utils/Makefile.am
   gnucash/trunk/src/core-utils/core-utils.i
   gnucash/trunk/src/python/Makefile.am
   gnucash/trunk/src/python/gncmod-python.c
Log:
[Python] Export core-utils SWIG wrappers to Python.

Modified: gnucash/trunk/src/base-typemaps.i
===================================================================
--- gnucash/trunk/src/base-typemaps.i	2011-11-20 10:20:15 UTC (rev 21599)
+++ gnucash/trunk/src/base-typemaps.i	2011-11-20 18:27:00 UTC (rev 21600)
@@ -93,7 +93,7 @@
 }
 
 %typemap(in) gchar * {
-    $1 = ($1_type)PyString_AsString($input);
+    $1 = ($1_ltype)PyString_AsString($input);
 }
 
 %typemap(out) gchar * {

Modified: gnucash/trunk/src/core-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/core-utils/Makefile.am	2011-11-20 10:20:15 UTC (rev 21599)
+++ gnucash/trunk/src/core-utils/Makefile.am	2011-11-20 18:27:00 UTC (rev 21600)
@@ -14,7 +14,7 @@
   gnc-main.c \
   gnc-path.c \
   gnc-uri-utils.c \
-  swig-core-utils.c
+  swig-core-utils-guile.c
 
 libgnc_core_utils_la_LIBADD = \
   ${GUILE_LIBS} \
@@ -24,6 +24,7 @@
   ${GCONF_LIBS} \
   ${QOF_LIBS}
 
+
 noinst_HEADERS = \
   binreloc.h \
   gnc-main.h \
@@ -38,10 +39,15 @@
   gnc-uri-utils.h
 
 if BUILDING_FROM_SVN
-swig-core-utils.c: core-utils.i ${top_srcdir}/src/base-typemaps.i
+swig-core-utils-guile.c: core-utils.i ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
 	-I${top_srcdir}/src -o $@ $<
+if WITH_PYTHON
+swig-core-utils-python.c: core-utils.i ${top_srcdir}/src/base-typemaps.i
+	$(SWIG) -python -Wall -Werror $(SWIG_ARGS) \
+	-I${top_srcdir}/src -o $@ $<
 endif
+endif
 
 AM_CPPFLAGS = \
   ${GUILE_INCS} \
@@ -62,6 +68,29 @@
 SCM_FILE_LINKS = ${gncmod_DATA}
 endif
 
+if WITH_PYTHON
+
+lib_LTLIBRARIES += libgnc-core-utils-python.la
+
+libgnc_core_utils_python_la_SOURCES = \
+	swig-core-utils-python.c
+
+libgnc_core_utils_python_la_LIBADD = \
+	${PYTHON_LIBS} \
+	${top_builddir}/src/core-utils/libgnc-core-utils.la
+
+libgnc_core_utils_python_la_CPPFLAGS = \
+  ${GLIB_CFLAGS} \
+  ${GCONF_CFLAGS} \
+  ${GTK_MAC_CFLAGS} \
+  ${QOF_CFLAGS} \
+  ${PYTHON_CPPFLAGS} \
+  -I${top_srcdir}/src/libqof/qof \
+  -I${top_builddir}/src \
+  -I${top_srcdir}/src
+
+endif
+
 .scm-links: 
 	$(RM) -rf gnucash
 	mkdir -p  gnucash

Modified: gnucash/trunk/src/core-utils/core-utils.i
===================================================================
--- gnucash/trunk/src/core-utils/core-utils.i	2011-11-20 10:20:15 UTC (rev 21599)
+++ gnucash/trunk/src/core-utils/core-utils.i	2011-11-20 18:27:00 UTC (rev 21600)
@@ -7,10 +7,22 @@
 #include <gnc-filepath-utils.h>
 #include <gnc-locale-utils.h>
 #include <glib.h>
-
+%}
+#if defined(SWIGGUILE)
+%{
 SCM scm_init_sw_core_utils_module (void);
 %}
-
+#endif
+#if defined(SWIGPYTHON)
+%{
+#if PY_VERSION_HEX >= 0x03000000
+PyObject*
+#else
+void
+#endif
+    SWIG_init (void);
+%}
+#endif
 %import "base-typemaps.i"
 
 gboolean gnc_is_debugging(void);
@@ -41,6 +53,7 @@
 
 const char * gnc_locale_default_iso_currency_code (void);
 
+#if defined(SWIGGUILE)
 %rename ("gnc-utf8?") wrap_gnc_utf8_validate;
 %inline %{
   /* This helper function wraps gnc_utf8_validate() into a predicate. */
@@ -50,3 +63,6 @@
     return gnc_utf8_validate(str, -1, 0);
   }
 %}
+#elsif defined(SWIGPYTHON)
+gboolean gnc_utf8_validate(const gchar *, gssize, const gchar**);
+#endif

Modified: gnucash/trunk/src/python/Makefile.am
===================================================================
--- gnucash/trunk/src/python/Makefile.am	2011-11-20 10:20:15 UTC (rev 21599)
+++ gnucash/trunk/src/python/Makefile.am	2011-11-20 18:27:00 UTC (rev 21600)
@@ -11,7 +11,7 @@
 
 libgncmod_python_la_LIBADD = \
   ${top_builddir}/src/gnc-module/libgnc-module.la \
-  ${top_builddir}/src/core-utils/libgnc-core-utils.la \
+  ${top_builddir}/src/core-utils/libgnc-core-utils-python.la \
   ${top_builddir}/src/app-utils/libgncmod-app-utils-python.la \
   ${PYTHON_LIBS} \
   ${PYTHON_EXTRA_LIBS} \

Modified: gnucash/trunk/src/python/gncmod-python.c
===================================================================
--- gnucash/trunk/src/python/gncmod-python.c	2011-11-20 10:20:15 UTC (rev 21599)
+++ gnucash/trunk/src/python/gncmod-python.c	2011-11-20 18:27:00 UTC (rev 21600)
@@ -39,8 +39,10 @@
 
 #if PY_VERSION_HEX >= 0x03000000
 extern PyObject* PyInit__sw_app_utils(void);
+extern PyObject* PyInit__sw_core_utils(void);
 #else
 extern void init_sw_app_utils(void);
+extern void init_sw_core_utils(void);
 #endif
 
 int
@@ -53,8 +55,10 @@
     Py_Initialize();
 #if PY_VERSION_HEX >= 0x03000000
     PyInit__sw_app_utils();
+    PyInit__sw_core_utils();
 #else
     init_sw_app_utils();
+    init_sw_core_utils();
 #endif
 
     /*



More information about the gnucash-changes mailing list