I am unsure if the rust string is unicode or not. Anyhow J strings are utf8 and you may need to convert between unicode and utf8 inside the interface.
On Tue, Apr 18, 2023 at 2:15 AM Michal Wallace <[email protected]> wrote: > That makes sense now. Thanks, Bill. > > JPrez is (or rather was) a console application, so I wanted to make a new > frontend > that could draw a text console quickly, but also do the audio recordings. > > My first attempt was to write an extension for the Godot game engine using > rust, leading to: > > https://github.com/tangentstorm/jlang-rs > https://github.com/tangentstorm/jlang-rs-gd > > This is nice because I can mix my J REPL presentations with other effects > from godot's animation > system. But while Godot plays audio just great, it's recording system is > incredibly buggy and I wind > up having to record the same thing many times (because the wav file has no > sound or is nothing > but static about 50% of the time) > > Anyway, I built my new console control in free pascal using a nice canvas > control and then added > some audio components so I can record. > > For now, I'm still planning to use the Jwd mechanism to drive playing back > the audio files > from J, but I was thinking I might try to wrap the pascal canvas control as > a jgl implementation, > so I could draw directly onto the "terminal" from J. > > I was just asking about jqt because I like your idea of breaking the > frontend into a dll > coupled with a small executable that calls it. Now that I understand how it > works, maybe > I can do the same thing. :) > > > > On Mon, Apr 17, 2023 at 1:39 PM bill lam <[email protected]> wrote: > > > I should have said both j and jqt can call each other directly using the > > visible dllexport function name as entry points. > > jlib.h in jsource repos and gl2.ijs etc in qt ide addon. > > The function prototype of gl2 are listed in gl2.ijs of qt ide. > > > > gl2class.h is the implementation already. > > > > If you look at gl2.cpp it includes gl2class.h. > > > > However I am puzzled, if you write your frontend then jqt won't be used > at > > all. You need to implement your own gui functions including gl2.. > > > > > > On Tue, Apr 18, 2023, 12:57 AM Michal Wallace <[email protected]> > > wrote: > > > > > 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 > > > > > ---------------------------------------------------------------------- > > 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
