Lovely! That’s good stuff though I suppose the debugging/FFI story could use help.
Curious to see your J<—>Godot stuff! > On Dec 7, 2021, at 7:32 AM, Michal Wallace <[email protected]> wrote: > > Aha! It's working now. The basic flow was right, I just needed a lot of > fiddling with the rust translations of the types. > > Thanks, everyone! > > > > > On Tue, Dec 7, 2021 at 7:18 AM Michal Wallace <[email protected]> > wrote: > >> Nice! My actual goal is to get J talking to godot (game engine). As it >> happens, rust and haskell are apparently two of the most-developed languages >> for writing godot extensions, so if this fails I may try your haskell >> bindings. >> >> I got some rudimentary free pascal bindings working without much hassle >> many years ago, so I think my problem really >> is just not understanding the rust side, but I could have also >> mis-translated something on the J end and just don't see it yet. >> >> (as for the crash, that's pretty much what i get too.) I think the j.so or >> j.dylib library needs to be in the >> current directory at the moment, and you'd need to change line 13 to tell >> it what the filename is. >> >> The debugger tells me this, but I have no idea what I'm looking at here: >> >> ; id = {0xffffffff}, range = [0x00000001800fe110-0x00000001800fe260), >> name="JDo" >> ; Source location: unknown >> 7FFCD598E110: 56 pushq %rsi >> 7FFCD598E111: 57 pushq %rdi >> 7FFCD598E112: 53 pushq %rbx >> 7FFCD598E113: 48 83 EC 40 subq $0x40, %rsp >> 7FFCD598E117: C5 F8 29 74 24 30 vmovaps %xmm6, 0x30(%rsp) >> 7FFCD598E11D: 48 8B 05 14 DC 3B 00 movq 0x3bdc14(%rip), %rax >> 7FFCD598E124: 48 31 E0 xorq %rsp, %rax >> 7FFCD598E127: 48 89 44 24 28 movq %rax, 0x28(%rsp) >> 7FFCD598E12C: 48 89 4C 24 20 movq %rcx, 0x20(%rsp) >> 7FFCD598E131: 8A 81 ED 01 00 00 movb 0x1ed(%rcx), %al >> 7FFCD598E137: 84 C0 testb %al, %al >> 7FFCD598E139: 0F 85 C6 00 00 00 jne 0x7ffcd598e205 ; <+245> >> 7FFCD598E13F: 80 B9 E0 52 00 00 02 cmpb $0x2, 0x52e0(%rcx) >> >> I think maybe this is the start (??) of the code for JDo, so it might be >> the parameter is an invalid pointer, but I don't know how to interpret this. >> >> >> On Mon, Dec 6, 2021 at 8:47 PM Vanessa McHale <[email protected]> wrote: >> >>> Hm, I’m not familiar with the dlopen crate, had you used it before? I >>> can’t tell what’s going on under the hood! >>> >>> I was able to get FFI working by looking at >>> https://github.com/jsoftware/stats_jserver4r/blob/4c94fc6df351fab34791aa9d78d158eaefd33b17/source/lib/j2r.c >>> < >>> https://github.com/jsoftware/stats_jserver4r/blob/4c94fc6df351fab34791aa9d78d158eaefd33b17/source/lib/j2r.c> >>> and >>> https://github.com/jsoftware/stats_jserver4r/blob/4c94fc6df351fab34791aa9d78d158eaefd33b17/source/lib/r2j.c >>> < >>> https://github.com/jsoftware/stats_jserver4r/blob/4c94fc6df351fab34791aa9d78d158eaefd33b17/source/lib/r2j.c >>>> >>> >>> I got Haskell bindings: https://github.com/vmchale/j-hs < >>> https://github.com/vmchale/j-hs> but BUT interestingly one test fails on >>> older GHCs… can’t tell why and I never did get around to debugging it. >>> >>> BTW I get >>> >>> error: test failed, to rerun pass '--lib' >>> >>> Caused by: >>> process didn't exit successfully: >>> `/private/tmp/jlang-rs/target/debug/deps/jlang-1c90c81a3f6fae1c >>> --nocapture` (signal: 11, SIGSEGV: invalid memory reference) >>> >>> on mac >>> >>>> On Dec 6, 2021, at 7:22 PM, bill lam <[email protected]> wrote: >>>> >>>> I don't know rust at all. What exactly do you expect and how it failed? >>>> >>>> On Tue, 7 Dec 2021 at 9:10 AM Michal Wallace <[email protected]> >>>> wrote: >>>> >>>>> ... It was not a successfu attempt. :) >>>>> >>>>> https://github.com/tangentstorm/jlang-rs/blob/main/src/lib.rs >>>>> >>>>> The basic plumbing seems to work unless I actually call JDo() on line >>> 75 >>>>> here. >>>>> Any rust fans out there who might be able to help me figure this out? >>>>> >>>>> -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
