[liblouis-liblouisxml] Re: Using liblouis within an Android app.

  • From: Dave Mielke <dave@xxxxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Wed, 6 Jan 2016 08:33:41 -0500

[quoted lines by Bert Frees on 2016/01/06 at 11:40 +0100]

As a matter of fact, very little code in liblouis-java has to do
with JNA. The little code that has to do with JNA is all about
converting values from one type to another, for those cases that
aren't handled by JNA out of the box. (Which I imagine needs to
be done in JNI too.

Not so, for the most part, the way I've done it.

For the int arrays, I use Java int[]. All that requires in the C code is to pin
an array (lock it in place) before referencing it, and then to unpin it when
done.

For Srings, there are two possibilities. One is to use JNI functions to convert
them to or from UTF-8. The other is to access them as C 16-bit unsigned integer
arrays (type provided by JNi as jchar).

One bit that's a bit more complicated is the need to return several integers
(three, in fact: input length, output length, cursor offset). Since an integer
is a primitive, rather than an Object, in Java, I can see some people jumping
through hoops to do it. What I chose to do was to pass them via a three-element
int[] array. It works very nicely that way.

Afterall, JNA is built on JNI.) All other
code either adds real functionality, or tries to make the library
more object-oriented/Java-like, as you do.

Regarding the localisations: It would indeed be nice to have them
available for all Java users, and by extension all users in
general. Your ideas are welcome. We've discussed this issue many
times before but never came to a conclusion.

The C way is to use gettext() and friends, and message catalogs. While I
haven't looked for it, it wouldn't surprise me if there's an implementation of
gettext() for Android.

We've often discussed the issue of localisation in the same
breath as the issue of metadata and discovery.

Meta-data is actually a separate issue. Yes, I think each table should contain
its own meta-data. I'd sure much prefer if each table would contain its own
description rather than (as I've done) make it part of the code. At least, in
Java, it's part of the specific enumeration for a table, and, further more,
externally defined within an Android string resources file.

The reason I've added the descriptions, by the way, is so that the tables can
ultimately be presented to the user in a human-readable list for selection.

--
Dave Mielke | 2213 Fox Crescent | The Bible is the very Word of God.
Phone: 1-613-726-0014 | Ottawa, Ontario | http://Mielke.cc/bible/
EMail: Dave@xxxxxxxxx | Canada K2A 1H7 | http://FamilyRadio.org/
For a description of the software, to download it and links to
project pages go to http://liblouis.org

Other related posts: