Guile API
Alex Weiss
alexweiss at theplate.com
Sat Nov 7 17:21:11 EST 2015
Thanks for your help. I saw that code. However, I seem to be missing something. While the c function qof_session_new is exposed as qof-session-new, the same is not true for qof_session_begin.
In my guile file I include gnucash bindings as so....
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(gnc:module-load "gnucash/engine" 0)
But a call to (qof-session-begin (qof-session-new) "file://agnucashfile.gnucash" #t #f #t)) is considered a call to "Unbound variable: qof-session-begin).
Is qof-session-begin in a different module?
Thanks for your help again,
> Sent: Thursday, October 29, 2015 at 12:14 PM
> From: "John Ralls" <jralls at ceridwen.us>
> To: "Alex Weiss" <alexweiss at theplate.com>
> Cc: gnucash-user at gnucash.org
> Subject: Re: Guile API
>
>
> > On Oct 29, 2015, at 8:04 AM, Alex Weiss <alexweiss at theplate.com> wrote:
> >
> > I was considering scripting GnuCash using its Guile API rather that it's Python API? Am I crazy to assume that the Guile API is as rich an the Python API?
> >
> > The first stumbling block I have noticed is simply creating what the Python API calls a "session" - a connection to gnucash will allows for the input and retrieval of GnuCash data. The Python API Session object seems to wraps the c functions: qof_session_new, qof_session_begin, and qof_session_load. The swig interface I found does not seem to export these out as Guile procedures.
> >
> > Any advice on using the Guile API in general or how to create a session using Guile in particular?
>
> Alex,
>
> Actually, more of GnuCash is exposed to Guile than to Python because Python can’t see the parts of GnuCash that are written in Scheme. Everything in the C API that’s exposed to one is exposed to the other; the differences in the SWIG interface files are just customizations needed to make a function work in the language in question. If there’s no customization it means that SWIG can figure out the right thing to do from the C header, and unless a function whose header is included in a SWIG file is specifically %excluded in the SWIG file it’s exported.
>
> What’s more, GnuCash links libguile and starts the Scheme interpreter very early, so you can actually customize the application with Scheme. This is how one adds custom reports.
>
> That aside, qof_session_new *is* mentioned explicitly in engine.i outside of the language-specific sections, at line 163. You can see it in action in src/engine/test/test-create-account.scm and test-dcm-query-import.scm
>
> Regards,
> John Ralls
More information about the gnucash-user
mailing list