Changeset: 4cb31334199a for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4cb31334199a Modified Files: clients/Tests/exports.stable.out monetdb5/modules/mal/manual.c monetdb5/modules/mal/manual.h monetdb5/modules/mal/manual.mal Branch: default Log Message:
Cleanup of manual generation Rely on external tools to render them further. diffs (truncated from 355 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -1266,7 +1266,6 @@ str IOprintBoth(Client cntxt, MalBlkPtr str IOprint_val(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); str IOprintf(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str IOprintfStream(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); -str IOprompt_val(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str IOtable(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str ITRbunIterator(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str ITRbunNext(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); @@ -1347,12 +1346,8 @@ str MALstartDataflow(Client cntxt, MalBl str MANIFOLDevaluate(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str MANIFOLDremapMultiplex(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); MALfcn MANIFOLDtypecheck(Client cntxt, MalBlkPtr mb, InstrPtr pci); -str MANUALcompletion(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); -str MANUALcreateIndex(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); -str MANUALcreateSection(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); -str MANUALcreateSummary(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); +str MANUALcreateOverview(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str MANUALhelp(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); -str MANUALsearch(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str MATHbinary_ATAN2dbl(dbl *res, const dbl *a, const dbl *b); str MATHbinary_ATAN2flt(flt *res, const flt *a, const flt *b); str MATHbinary_POWdbl(dbl *res, const dbl *a, const dbl *b); diff --git a/monetdb5/modules/mal/manual.c b/monetdb5/modules/mal/manual.c --- a/monetdb5/modules/mal/manual.c +++ b/monetdb5/modules/mal/manual.c @@ -16,141 +16,49 @@ #include "monetdb_config.h" #include "manual.h" - -static int cmpModName(Module *f, Module *l){ - return strcmp((*f)->name, (*l)->name); -} - -str -MANUALcreateIndex(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) -{ - stream *f = cntxt->fdout; - Module s = cntxt->nspace; - int j,z,rows,cols; - Symbol t; - InstrPtr sig; - Module list[256]; int k, top=0, ftop, fnd; - InstrPtr fcn[5000]; - int r, c, *x = NULL, x_sze = 0; - - (void) mb; - (void) stk; - (void) pci; - - if(s==NULL || f==NULL){ - return MAL_SUCCEED; - } - list[top++]=s; - while(s->outer){ list[top++]= s->outer;s=s->outer;} - - if(top>1) qsort(list, top, sizeof(Module), - (int(*)(const void *, const void *))cmpModName); - - cols = 4; - mnstr_printf(f,"@multitable @columnfractions .24 .24 .24 .24\n"); - for(k=0;k<top;k++){ - s= list[k]; - ftop = 0; - if( s->subscope) - for(j=0;j<MAXSCOPE;j++) - if(s->subscope[j]){ - for(t= s->subscope[j];t!=NULL;t=t->peer) { - sig= getSignature(t); - fnd = 0; - fnd= *getFunctionId(sig) == '#'; - for(z=0; z<ftop; z++) - if( strcmp(getFunctionId(fcn[z]),getFunctionId(sig))==0){ - fnd++; - break; - } - if( fnd == 0 && ftop<5000) - fcn[ftop++] = sig; - } - } - for(j=0; j<ftop; j++) - for(z=j+1; z<ftop; z++) - if( strcmp(getFunctionId(fcn[j]),getFunctionId(fcn[z])) >0) { - sig= fcn[j]; fcn[j]=fcn[z]; fcn[z]= sig; - } - mnstr_printf(f,"@" "item\n"); - rows = (ftop + cols - 1) / cols; - if (x == NULL) { - /* 2x* to allow for empty/skipped fields/columns */ - x_sze = 2 * cols * rows; - x = (int*) GDKmalloc(x_sze * sizeof(int)); - } else if (2 * cols * rows > x_sze) { - x_sze = 2 * cols * rows; - x = (int*) GDKrealloc(x, x_sze * sizeof(int)); - } - if( x == NULL){ - GDKerror("dumpManualOverview"MAL_MALLOC_FAIL); - return MAL_SUCCEED; - } - for (z = 0; z < rows; z++) { - x[cols * z] = z; - } - for (c = 1; c < cols; c++) { - for (r = 0; r < rows; r++) { - int i = (cols * r) + c - 1; - if (z < ftop && - (x[i] < 0 || strlen(getModuleId(fcn[x[i]])) + strlen(getFunctionId(fcn[x[i]])) < (size_t)(80 / cols))) { - x[i+1] = z++; - } else { - /* HACK to avoid long names running into next column in printed version */ - x[i+1] = -1; - } - } - } - z = 0; - for (r = 0; r < rows; r++) { - for (c = 0; c < cols; c++) { - str it[] = {"item", "tab"}; - mnstr_printf(f,"@" "%s\n", it[(c > 0)]); - if (x[z] != -1) { - mnstr_printf(f,"%s.%s\n", - getModuleId(fcn[x[z]]), getFunctionId(fcn[x[z]])); - } - z++; - } - } - } - mnstr_printf(f,"@end multitable\n"); - if (x != NULL) - GDKfree(x); - return MAL_SUCCEED; -} - /* * The manual help overview merely lists the mod.function names * together with the help oneliner in texi format for inclusion in the documentation. */ str -MANUALcreateSummary(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) +MANUALcreateOverview(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { + BAT *sig, *adr, *com; + bat *sx = getArgReference_bat(stk,pci,0); + bat *ax = getArgReference_bat(stk,pci,1); + bat *cx = getArgReference_bat(stk,pci,2); stream *f= cntxt->fdout; Module s= cntxt->nspace; int j,z; Symbol t; - InstrPtr sig; - Module list[256]; int k, ftop, fnd,top=0; - InstrPtr fcn[5000]; - str hlp[5000],msg; - str hlp_texi = NULL; - size_t hlp_texi_len = 0; + Module list[256]; + int k, ftop, top=0; + MalBlkPtr blks[25000]; + str hlp[25000]; + char buf[BUFSIZ], *tt; - (void) mb; - (void) stk; - (void) pci; + sig = BATnew(TYPE_void, TYPE_str, 0, TRANSIENT); + adr = BATnew(TYPE_void, TYPE_str, 0, TRANSIENT); + com = BATnew(TYPE_void, TYPE_str, 0, TRANSIENT); + if( sig == NULL || adr == NULL || com == NULL){ + if(sig) BBPunfix(sig->batCacheid); + if(adr) BBPunfix(adr->batCacheid); + if(com) BBPunfix(com->batCacheid); + } + BATseqbase(sig, 0); + BATseqbase(adr, 0); + BATseqbase(com, 0); + + BATkey(sig, TRUE); + BATkey(adr, TRUE); + BATkey(com, TRUE); if(s==NULL || f==NULL){ return MAL_SUCCEED; } list[top++]=s; - while(s->outer ){ list[top++]= s->outer;s=s->outer;} - - if(top>1) qsort(list, top, sizeof(Module), - (int(*)(const void *, const void *))cmpModName); + while(s->outer && top < 256 ){ list[top++]= s->outer;s=s->outer;} for(k=0;k<top;k++){ s= list[k]; @@ -159,76 +67,33 @@ MANUALcreateSummary(Client cntxt, MalBlk for(j=0;j<MAXSCOPE;j++) if(s->subscope[j]){ for(t= s->subscope[j];t!=NULL;t=t->peer) { - sig= getSignature(t); - fnd = 0; - fnd= *getFunctionId(sig) == '#'; - for(z=0; z<ftop; z++) - if( strcmp(getFunctionId(fcn[z]),getFunctionId(sig))==0){ - if( hlp[z] == 0) - hlp[z]= t->def->help; - fnd++; - break; - } - if( fnd == 0 && ftop<5000){ - hlp[ftop]= t->def->help; - fcn[ftop++] = sig; - } + hlp[ftop]= t->def->help; + blks[ftop]= t->def; + ftop++; + if( ftop == 25000) + throw(MAL,"manual.functions","Ouf of space"); } } - for(j=0; j<ftop; j++) - for(z=j+1; z<ftop; z++) - if( strcmp(getFunctionId(fcn[j]),getFunctionId(fcn[z])) >0) { - msg= hlp[j]; hlp[j]=hlp[z]; hlp[z]= msg; - sig= fcn[j]; fcn[j]=fcn[z]; fcn[z]= sig; - } - for(z=0; z<ftop; z++){ - mnstr_printf(f,"%s.%s", getModuleId(fcn[z]), getFunctionId(fcn[z])); - if( hlp[z] ) { - str hlp_ = hlp[z]; - size_t hlp_len = 2*strlen(hlp[z]) + 1; - if (hlp_texi == NULL) { - hlp_texi = (str) GDKmalloc(hlp_len); - hlp_texi_len = hlp_len; - } else if (hlp_len > hlp_texi_len) { - hlp_texi = (str) GDKrealloc(hlp_texi, hlp_len); - hlp_texi_len = hlp_len; - } - if (hlp_texi != NULL) { - str st, o = hlp_texi; - for ( st= hlp[z]; *st; st++){ - if (*st == '\n' || *st == '\t') - *o++ = ' '; - else - if( *st == '\\') { - *o++ = ' '; - st++; - } else - *o++ = *st; - } - *o++ = '\0'; - hlp_ = hlp_texi; - } - if (strlen(getModuleId(fcn[z])) + strlen(getFunctionId(fcn[z])) >= 20) { - /* HACK to avoid long names running into help text in printed version */ - } - mnstr_printf(f," | %s", hlp_); + buf[0]=0; + BUNappend(com, hlp[z] ? hlp[z]:buf, TRUE); + fcnDefinition(blks[z], getInstrPtr(blks[z],0), buf, TRUE, buf, BUFSIZ); + tt = strstr(buf,"address "); + if( tt){ + *tt = 0; + tt += 8; } - mnstr_printf(f,"\n"); + BUNappend(sig,buf,TRUE); + buf[0]=0; + BUNappend(adr,tt?tt:buf,TRUE); } } - if (hlp_texi != NULL) - GDKfree(hlp_texi); - return MAL_SUCCEED; -} -str -MANUALcompletion(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) -{ - str *text= getArgReference_str(stk,pci,1); - (void) mb; /* fool compiler */ - dumpHelpTable(cntxt->fdout, cntxt->nspace, *text,1); + BBPkeepref( *sx = sig->batCacheid); + BBPkeepref( *ax = adr->batCacheid); + BBPkeepref( *cx = com->batCacheid); + (void)mb; return MAL_SUCCEED; } @@ -252,25 +117,3 @@ MANUALhelp(Client cntxt, MalBlkPtr mb, M GDKfree(msg); return MAL_SUCCEED; } - -str -MANUALsearch(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) -{ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list