convert javah headers to D
snake.scaly at gmail.com
Mon Mar 16 12:41:08 PDT 2009
Mon, 16 Mar 2009 15:46:46 +0000 (UTC), Nicholas Jordan wrote:
> import placed in source file, will do a build later today as I am
> swamped with simple survival stuff today.
> What I don't get is, given that javap pulls headers, I tried to use
> the headers so that the JVM could call the dll. So far, so good,
> except that it would be much more in the style intent and manner of D
> to just write the calls and make the whole thing reliant on a header
> style we are trying to get away from.
> Thus, I don't know how to prototype the function. There is JNIEnv /
> jobject both of which resolve to "some computer stuff like we have
> always known it" ... the JNIEnv is double indirection, jobject amounts
> to something along the lines of a strongly typed pointer.
> If we could expose the function entry points to the JVM using D
> syntax, I am sure the entry from the JVM would be 190% better.
> That is what my question actually is: "How do I expose the function
> entry points to a running JVM - given that this code is called as a
> loadable runtime?"
> I re-coded my def file several times, think I have got the entire
> syntax starting to memorize. I put everything in there I could find in
> the docs, have to recode the EXPORTS as on of the editors I tried ate
> my sources last night.
> The massive array running down the middle is a bench hack as the
> compiler kept complaining about how I was doing the pointers. That is
> to be a data space some 1 to 100 kb by which I can pass data if I can
> not get anything else to work.
> The intent is to write Java code, bring in an image using EZTwain, do
> OCR on it.
I suggest you take an iterative approach. You're trying to make too
many non-trivial things at once: learn D, make Java correctly interface
with your DLL, make your DLL correctly interface with JRE, make your DLL
correctly interface with TWAIN drivers.
I suggest you create a very simple Java class, with a single native
function taking an integer argument and returning its square, and
implement this function in D. After this works, try adding another
function, taking a string as an argument and returning another string.
After you do that you'll have some grasp on D and on Java interfacing.
Then you may try implementing one of your actual functions, but even
then I suggest you skip TWAIN interactions first and fake them instead.
Or try to write a simple console application doing exclusively TWAIN
Currently, in your zarfOCR.d almost every single line requires fixing.
More information about the Digitalmars-d-learn