|
From: John B. <jo...@ma...> - 2003-11-05 16:00:23
|
> John you are my hero!!!!
> You saved me a whole hell of a lot of time
> This now works... and I assume the bindings will be just as easy in
> other languages :)
Yes, because your normal api is a very thin shim on top of your C api, =
all the languages will work the same way, with exactly the same api. =
Makes documenting really easy too.
I see that you added rlib_set_output_format_from_text() so as to get =
rid of the ENUM -- that's the right way to do it.
This isn't a big deal, but if you added two bools to the struct ("test" =
below) you hold, with
bool has_initialized;
bool has_executed;
then when rlib_add_datasource_mysql() is called, rlib_init(); could be =
called automatically, and the same thing with spool() calling =
execute().
Can one re-use a report object, or must it be freed after use? If it =
has to be freed, then you might as well make spool() call free().
Another easy feature, that'd be convenient, and make your api cleaner, =
would be a short-form call that does it all, namely:
rlib_mysql_report("localhost", "user", "password", "database", "select =
* from example", "PDF")
that gets rid of the need to keep an object around, and thus worrying =
about freeing memory. Memory leaking is probably my biggest worry =
about embedding rlib in another language, so wrapping the entire report =
request in a single stateless call gets rid of that. Also, I've =
noticed that the biggest problem people have with getting rlib to work =
is with the various api calls. Making this "short form" call the one =
most people (at least initially) use would solve that. I can, of =
course, write this call for you if you like, but it's a trivial piece =
of C.
-john
> #!/usr/bin/python2.2
> import librlib;
> test =3D librlib.rlib_init();
> res =3D librlib.rlib_add_datasource_mysql(test, "mysql", "localhost",
> "user", "password", "database");
> librlib.rlib_add_query_as(test, "mysql", "select * from example",
> "example");
> librlib.rlib_add_report(test, "report.xml", "");
> librlib.rlib_set_output_format_from_text(test, "PDF");
> librlib.rlib_execute(test);
> librlib.rlib_spool(test);
> librlib.rlib_free(test);
> - bob
> On Tue, 2003-11-04 at 19:02, John Buckman wrote:
> > > swig looks really nice... I wish I saw that earlier... I'll go =
swig
> > > instead... so that way we can have tons of bindings ;)
> >=20
> > Yeah, I was one of the early developers on it, years and years ago. =
Once you define
> the C bindings, it'll do everything else for you. The only caveat is =
that it doesn't
> make crash-proof APIs (ie, no real parameter checking) but for rlib, =
that should be
> fine.
> >=20
|