Thanks Bill. I have JWd working now, but I'm a little confused about what you're trying to tell me about jQT.
You're saying that jqt can call j.dll directly, but what does that have to do with J calling functions defined in the frontend? How does jgl2 (for example) get the address of the corresponding c/c++ function? I see wd/gl2class.h in the qtide repo, and I see glcmds inside it, and I see that gl2.h marks a bunch of functions as "DllExport" but I don't yet see any place where some J script puts all the pieces together and tells it to look in the jqt.dll to get the implementation of jgl... (assuming that's what happens) Where should I look? On Sat, Apr 15, 2023 at 7:40 PM bill lam <[email protected]> wrote: > Jqt doesn't use 11!:x because it can call j.dll (libj.so) directly. Each > value of x in 11!:x is exposed as a c function in the frontend. If your > frontend is implemented in c/c++, then you can do the same without using > 11!:x. > > However jandroid uses 11!:x interface because libj is C while jandroid is > written in java. The interface between java and C needs a jni wrapper, > therefore it is more convenient to reduce the number of interface calls by > using 11!:x callback. > > In the prototype of Jwd, the pres the pointer of of result A (pointer to an > AD structure), typically the AD structure is allocated by the frontend > using Jga api (see jlib.h). > > You need not bother with the AC field. > The AR (rank) contains other information in its high bits so that you must > mask it to the lowest 7 bits only (though it seems safe enough to mask the > lowest 8 bits, Henry should know better here). > > You can browse the jandroid repository and also the io.c and andjnative.c > in jsource repository. > > On Sun, 16 Apr 2023 at 6:36 AM Michal Wallace <[email protected]> > wrote: > > > Hrm. That does help a little bit. There's definitely still something > called > > JWd defined in JLib. > > > > Here is what I know so far: > > (actually more than when I started typing this, so... I'll probably move > > this to the wiki at some point.) > > > > When you write a J frontend, you have to call a function called JSM > > (session manager) > > and you pass in the addresses of four callback functions that your > frontend > > implements: > > > > JWr -> session calls this to output to whatever "terminal" you set up > > JWd -> this window driver thing. > > JRd -> session calls this when it needs to read a line of input > > ??? -> something reserved for future use? > > > > JWd does still seem to be hooked up to 11!:x (weird to see that called x > > instead of n!) > > > > The signature looks like this: > > > > int _stdcall Jwd(JS jt, int x, A parg, A* pres, C* loc); > > -- https://github.com/jsoftware/jsource/blob/master/jsrc/jlib.h#L111 > > > > The arguments seem to be: > > > > jt -> address of j session object > > x -> the 'n' in 11!:n > > parg -> the y argument to (11!n) (a pointer to a J array) > > pres -> the result array (you modify this to put your return value > here) > > loc -> a locale name (?) > > > > There is an example J frontend here: > > > > https://github.com/jsoftware/jsource/blob/master/jsrc/jfex.c > > > > It has this comment for its implementation of Jwd (which is missing the > loc > > parameter): > > > > // J calls for 11!:x y - demonstrates all features of jwdw and jwdp > > // pa is y and result array (if any) is returned in pz > > // return pz > > // 0 - MTM i.0 0 > > // -1 A - A result > > // -2 A - A is pairs of null terminated strings for event table > > // n - EVDOMAIN etc > > > > > > The 'parg' argument has the following fields, which I am expecting to > match > > the structure defined here: > > > > https://www.jsoftware.com/ioj/iojNoun.htm > > > > k -> "offset of ravel with respect to byte 0 of the array" > > f -> a flag of some sort > > m -> "maximum number of bytes in ravel" > > t -> the type > > c -> reference count > > n -> the length of the data > > r -> rank > > s -> pointers to shape and value > > > > My implementation of Jwd just prints out the arguments... > > > > JWd(x:2000, a:[k: 64 f: 0 m: 117321808 t: 2 c: $8000000000000001 n: 5 > r: > > $BAADF00D062E0001]) > > > > I guess really my main problem is I don't understand how to interpret the > > "rank" and "reference count" fields. > > I'd expect both of these to be small positive integers, like what I see > in > > the ioj. > > > > Without the rank, I don't know how to parse the shape and value. > > > > Hrm. I guess technically I know from the docs that all (11!:n) are rank > 1, > > so maybe I can just ignore that field? > > > > I will investigate further. > > > > > > On Sat, Apr 15, 2023 at 5:01 PM Raul Miller <[email protected]> > wrote: > > > > > Jwd sounds like version 6 of J. This predates Jqt. > > > > > > There's some docs at > > > > > > https://www.jsoftware.com/docs/help602/user/win_driver_cmd_ref_overview.htm > > > > > > I hope this helps, > > > > > > -- > > > Raul > > > > > > On Sat, Apr 15, 2023 at 4:57 PM Michal Wallace < > [email protected] > > > > > > wrote: > > > > > > > > Hey all, > > > > > > > > I've been working on JPrez again -- a console-based presentation tool > > > > that can record and play back interactions with a J REPL. > > > > > > > > It also lets you specify text to be recorded for voice overs to > narrate > > > the > > > > interaction (for making videos), and over the past week I've embedded > > > > JPrez inside a windows binary that looks like a normal text console > but > > > > can peek inside JPrez and actually let me record and play audio for > > > > the individual voice over lines. > > > > > > > > However, right now I'm doing everything from the host application. It > > > polls > > > > Jprez to see what's on the screen and what the current line of text > is > > > > (jprez suggests a filename for a corresponding wav file). > > > > > > > > That all works fine for recording one line at a time, but if I want > to > > > > actually > > > > play the presentation, I'd much rather have J drive the interaction. > > > > > > > > I basically already have a J front end, but I don't know what to do > > with > > > > Jwd, > > > > or how to use it from the J side. I've picked up that it's using > 11!:n > > > > under the > > > > hood, but I haven't found much information about how it's meant to be > > > used. > > > > > > > > Do any docs exist? > > > > > > > > Where should I look in the jsource and jQt code bases to find > examples? > > > > > > > > Thanks! > > > > > > > > -Michal > > > > > ---------------------------------------------------------------------- > > > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
