Mercurial > hg > jgplsrc
comparison s.h @ 0:e0bbaa717f41 draft default tip
lol J
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Mon, 25 Nov 2013 11:56:30 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e0bbaa717f41 |
---|---|
1 /* Copyright 1990-2011, Jsoftware Inc. All rights reserved. */ | |
2 /* License in license.txt. */ | |
3 /* */ | |
4 /* For Symbol Tables aka Locales */ | |
5 | |
6 | |
7 #define LOCPATH(g) ((*AV(g)+jt->sympv)->val ) | |
8 #define LOCNAME(g) ((*AV(g)+jt->sympv)->name) | |
9 #define NMHASH(p,s) (*(s)+(p)+99991L*(UC)(s)[(p)-1]) | |
10 | |
11 | |
12 /* macro to define a function that walks through a symbol table */ | |
13 /* f - name of derived function */ | |
14 /* T - for z, C datatype */ | |
15 /* TYPE - for z, J datatype */ | |
16 /* COUNT - for z, # of initial items for z */ | |
17 /* COL - for z, # columns */ | |
18 /* SELECT - selection function on a name */ | |
19 /* PROCESS - processing on a selected name */ | |
20 | |
21 #define SYMWALK(f,T,TYPE,COUNT,COL,SELECT,PROCESS) \ | |
22 F1(f){A z;I*e,i,j,k,m=0,n;L*d;T*zv; \ | |
23 RZ(w); \ | |
24 n=AN(w); e=1+AV(w); k=*e; \ | |
25 GA(z,(TYPE),(COUNT)*(COL),(1<(COL))?2:1,0); \ | |
26 if(1<(COL)){*AS(z)=(COUNT); *(1+AS(z))=(COL);} \ | |
27 zv=(T*)AV(z); \ | |
28 for(i=1;i<n;++i,k=*++e)while(j=k){ \ | |
29 d=j+jt->sympv; \ | |
30 k=d->next; \ | |
31 if((d->name)&&(SELECT)){ \ | |
32 if(m==*AS(z)){RZ(z=ext(0,z)); zv=(m*(COL))+(T*)AV(z);} \ | |
33 {PROCESS;} \ | |
34 ++m; \ | |
35 }} \ | |
36 AN(z)=m*(COL); *AS(z)=m; \ | |
37 R z; \ | |
38 } | |
39 |