9 messages in net.java.dev.jna.usersRe: [jna-users] Wrapping a C api to c...
FromSent OnAttachments
Richard OteroOct 12, 2007 3:59 pm 
Albert StrasheimOct 12, 2007 4:39 pm 
Albert StrasheimOct 12, 2007 5:51 pm 
Albert StrasheimOct 12, 2007 6:00 pm 
Timothy WallOct 13, 2007 6:05 am 
Timothy WallOct 13, 2007 7:05 am 
Timothy WallOct 13, 2007 7:27 am 
Albert StrasheimOct 13, 2007 10:55 am 
Richard OteroOct 14, 2007 2:50 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Wrapping a C api to control Matlab using Java (with example)Actions...
From:Albert Strasheim (full@gmail.com)
Date:Oct 12, 2007 5:51:19 pm
List:net.java.dev.jna.users

Hello,

Engine - A handle to a MATLAB engine object. int engClose(Engine *ep); int engEvalString(Engine *ep,const char *string); int engGetVisible(Engine *ep, bool *value); Engine *engOpen(const char *startcmd); Engine *engOpenSingleUse(const char *startcmd, void *dcom, int *retstatus); int engOutputBuffer(Engine *ep, char *p, int n); int engSetVisible(Engine *ep, bool value);

Here's my first untested attempt for the Engine part, minus a Structure for mxArray (presently just wrapped as a Pointer):

public interface EngineLibrary extends Library { EngineLibrary INSTANCE = (EngineLibrary2) Native.loadLibrary("libeng", EngineLibrary.class); int engEvalString(Pointer ep, String string); Pointer engOpenSingleUse(String startcmd, Pointer reserved, IntByReference retstatus); int engSetVisible(Pointer ep, boolean newVal); int engGetVisible(Pointer ep, ByteByReference bVal); Pointer engOpen(String startcmd); int engClose(String ep); Pointer engGetVariable(Pointer ep, String name); int engPutVariable(Pointer ep, String name, Pointer ap); int engOutputBuffer(Pointer ep, ByteBuffer buffer, int buflen); }

Once you set an output buffer with engOutputBuffer, you're going to have make sure you keep around a reference to it for as long as the engine is open. I think you'll also have to allocate it as a direct buffer so that you will be able to see the output MATLAB writes.

Next up, mxArray...

Regards,

Albert