git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4996 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2001-07-25 05:28:11 +00:00
parent 85ede8179f
commit a96b0fd0b5
3 changed files with 31 additions and 6 deletions

View File

@ -40,7 +40,7 @@ INCLUDES = \
-I${top_srcdir}/src/engine
libgncswig_la_LIBADD = \
-lgncengine \
-lgncengine -lxml \
@GLIB_LIBS@
@ -53,7 +53,9 @@ SWIG_INPUT_HDRS := \
${top_srcdir}/src/engine/Scrub.h \
${top_srcdir}/src/engine/Transaction.h \
${top_srcdir}/src/engine/date.h \
${top_srcdir}/src/engine/gnc-book.h
${top_srcdir}/src/engine/gnc-book.h \
${top_srcdir}/src/engine/gnc-engine.h \
${top_srcdir}/src/engine/gnc-numeric.h
## This is kinda ugly, but swig insists that the .so file be named the
## same as the .pm file, and automake won't tolerate libraries that

View File

@ -11,11 +11,20 @@ use gnucash;
package gnucash;
die "Usage: $0 <filename>" if $#ARGV < 0;
print "its $ARGV[0]\n";
print "Will load $ARGV[0]\n";
gnucash::gnc_engine_init(0, $ARGV);
$session = gnucash::gnc_book_new ();
gnucash::gnc_book_begin ($session, $ARGV[0], 0, 0);
gnucash::gnc_book_load ($session);
$rc = gnucash::gnc_book_begin ($session, $ARGV[0], 0, 0);
if ($rc != 1)
{
$err = gnucash::gnc_book_get_error ($session);
print "Could not find $ARGV[0], errrocode=$err\n";
}
$rc = gnucash::gnc_book_load ($session);
die "Could not load $ARGV[0]\n" if $rc != 1;
$grp = gnucash::gnc_book_get_group ($session);
$numacc = gnucash::xaccGroupGetNumAccounts ($grp);
@ -24,7 +33,8 @@ print "Loaded $numacc accounts\n\n";
for ($i=0; $i<$numacc; $i++) {
$acct = gnucash::xaccGroupGetAccount ($grp, $i);
$acctname = gnucash::xaccAccountGetName ($acct);
$baln = gnucash::xaccAccountGetBalance ($acct);
$numeric_baln = gnucash::xaccAccountGetBalance ($acct);
$baln = gnucash::gnc_numeric_to_double ($numeric_baln);
print "\tAccount: $acctname \tBalance: $baln\n";
}

View File

@ -60,6 +60,19 @@
// printf ("Info: gboolean input arg is %ld \n", * ($target));
}
/* cut and paste of above, do exactly the same thing for GNCBackendError */
%typemap(perl5, out) GNCBackendError {
$target = newSViv ((IV) *($source));
/*
* An alternate way of writing this code would have been ...
* $target = sv_newmortal ();
* sv_setiv ($target, (IV) $source);
*/
argvi ++;
// printf ("Info: converted return GNCBackendError secs to %d \n", (int) SvIV($target));
}
/* --------------------------------------------------------- */
#ifdef DOESNT_WORK_DONT_KNOW_WHY