hi, the subject is inflammatory.
appended is a program that does less than jconsole.
it would be great if j602 exposed more of the j internals.
here's an example session:

$ gcc jx.c libj601.so -o jx && ./jx
/tmp/ccWx0XRb.o: In function `main':
jx.c:(.text+0x36e): warning: the `gets' function is dangerous and
should not be used.
1
boolean,rank 0,shape
1.0
boolean,rank 0,shape
2 3
integer,rank 1,shape 2
i. 1 4
integer,rank 2,shape 1 4
+/i.4
integer,rank 0,shape

... and the source
$ cat jx.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*
to list all symbols in the dll:
  $ objdump -T libj601.so  |grep \ J
*/
#define tf typedef
tf int I;tf void V;tf char C;tf double D;tf float F;tf C*S;tf V*P;
#define xt extern
#define O printf
#define R return
#define W while
/*return 0 on error or handle to be used as first arg to the other funcsi
** but what is the parameter? */
xt JInit(I x);
/* return 0 or error code unless noted */
xt JFree(I h);
xt JDo(I h,S s); /* execute the j sentence s */
xt JGetM(I h,S n,I*t,I*r,I**s,P d); /* handle,name,type,rank,shape,data */
xt JSetM(I h,S n,I*t,I*r,I**s,P d);
xt S JGetA(I h,I,S); /* returns 0 for error or pointer to 3!:1 format */
xt JSetA(I,I,S,I,P);
/* what about JErrorTextM JSM JGetLocale Jga ? */
/* types  see doc for 3!0 at system/extras/help/dictionary/dx003.htm */
S tss[16]={"boolean","literal","integer","floating point","complex","boxed",
"extended integer","rational","sparse boolean","sparse literal",
"sparse integer","sparse floating point","sparse complex","sparse boxed",
"symbol","unicode"};
ti(t){R logf(t)/logf(2);}
S ts(t){R tss[ti(t)];}
#define NL O("\n")
Ot(t,r,s)I*s;{I i=0;O("%s,rank %d,shape",ts(t),r);W(i<r)O(" %d",s[i++]);NL;}
#define sO sprintf
#define eO(...) fprintf(stderr,__VA_ARGS__)
jerr(x){C s[99];if(x){ sO(s,"l87=.%d",x-1); jd(s); jd("l87=.>l87{9!:8''");
{I i,r,*s,t;V*d;jg("l87",&t,&r,&s,&d);eO("! %s\n",d);}
}}

I j_; ji(){j_=JInit(0);j_||eO("JInit failed");}
jf(){R jerr(JFree(j_));} jd(S s){R jerr(JDo(j_,s));}
jg(S n,I*t,I*r,I**s,P d){R jerr(JGetM(j_,n,t,r,s,d));}
js(S n,I*t,I*r,I**s,P d){R jerr(JSetM(j_,n,t,r,s,d));}
S jh(I i,S s){S x=JGetA(j_,i,s);R x?x:(S)jerr(!x);}
jt(I i,S s,I j,P p){R jerr(JSetA(j_,i,s,j,p));}
describe(S x){I i,r,*s,t;V*d;jg(x,&t,&r,&s,&d);Ot(t,r,s);}
main()
{I i,r,*s,t;V*d;C b[99],bb[99];ji();
while(gets(b))sO(bb,"m97=.%s",b),jd(bb),describe("m97");
jf();
}
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to