source: branches/ali/AISC_COM/AISC/aisc_global.pa

Last change on this file was 18731, checked in by westram, 3 years ago
  • remove generated whitespace.
    • code generator depended on trailing whitespace (fixed using variable EMPTY)
  • fix trailing whitespace in text.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1IF $(argc) < 5
2    ERROR Wrong number of parameters[$(argc)]. Usage: aisc aisc_global.pa xxx.aisc outfile extern_file
3ENDIF
4
5DATA AISC { $(#FILE $(argv[2])) };
6DUMPDATA DUMP/aisc_global.pa__$(argv[2]).dump
7OPEN save $(argv[3])
8
9MOVETO $(AISC/PROJECT)
10CREATE $(pre) = $(OBJECT_KEY)_
11CREATE $(max_key) = $(MAX_KEY)
12CREATE $(max_obj) = $(MAX_OBJECT)
13CREATE $(i)
14CREATE $(termptrlist) = $1NULp$n};$n
15CREATE $(termflaglist) = $10$n};$n
16
17OUT save
18
19MOVETO $(DATA/.)
20
21P /* -----------------------------------------------------------------
22P  * Created automagically from ../$(argv[2])
23P  *                       and ../$(argv[4])
24P  * using aisc-script '../AISC/aisc_global.pa'
25P  * DO NOT EDIT THIS FILE!!!
26P  * ----------------------------------------------------------------- */
27--
28P #include <aisc_server.h>
29--
30
31# create and clear obj and key list
32FOR $(i) = 0 TO $(max_obj)
33    CREATE $(obj[$(i)]) = NULp,
34ENDFOR
35FOR $(i) = 0 TO $(max_key)
36    CREATE $(key[$(i)]) = NULp,
37ENDFOR
38
39# generate object names struct
40FOR $(STRUCT)
41    IF $(SKEY)
42        IF $(obj[$(SKEYC)])
43            SET $(obj[$(SKEYC)]) = "$(pre)$(SKEY)",
44        ELSE
45            ERROR Increase definition of MAX_OBJECT to $(SKEYC)
46        ENDIF
47    ENDIF
48ENDFOR
49
50P const char *aisc_object_names[] = {
51GOSUB printobjlist
52P $(termptrlist)
53
54# generate attribute names structs
55CREATE $(nummer)
56CREATE $(aisc_string)
57FOR $(STRUCT)
58    IF $(SKEY)
59        GOSUB clearkeylist
60        SET $(nummer) = 0
61        SET $(aisc_string) = $(pre)$(SKEY)_
62        P static const char *$(pre)$(STRUCT)_attribute_names[] = {
63        GOSUB make_attr_names
64        GOSUB printkeylist
65        P $(termptrlist)
66    ENDIF
67ENDFOR
68P $n
69
70# generate attribute names struct list
71GOSUB clearobjlist
72P const char *aisc_attribute_names_list[] = {
73FOR $(STRUCT)
74    IF $(SKEY)
75        SET $(obj[$(SKEYC)]) = (const char *)$(pre)$(STRUCT)_attribute_names,
76    ENDIF
77ENDFOR
78GOSUB printobjlist
79P $(termptrlist)
80
81# generate function structs
82P typedef int* (*talking_function)(int *x, ...);
83P typedef talking_function *talking_function_ptr;
84--
85FOR $(STRUCT)
86    P extern talking_function aisc_talking_functions_create_$(STRUCT)[];
87    P extern int* (*aisc_talking_functions_get_$(STRUCT)[])();
88    P extern int* (*aisc_talking_functions_find_$(STRUCT)[])();
89    P extern int* (*aisc_talking_functions_copy_$(STRUCT)[])();
90    P extern int  (*aisc_talking_functions_set_$(STRUCT)[])();
91    --
92ENDFOR
93
94# generate d flags
95P int aisc_d_flags[] = {
96GOSUB clearobjflaglist
97FOR $(STRUCT)
98    IF $(SKEY)
99        SET $(i) = 0
100        FOR $({/TYPE)
101            IF $(TYPE) = dllh
102                SET $(i) = 1
103            ENDIF
104        ENDFOR
105        SET $(key[$(SKEYC)]) = $(i),$6// $(SKEY)
106    ENDIF
107ENDFOR
108GOSUB printobjlist
109P $(termflaglist)
110
111# generate callback tables
112P int* (**aisc_talking_functions_get[])() = {
113GOSUB print_talking_table,aisc_talking_functions_get_
114
115P int (**aisc_talking_functions_set[])() = {
116GOSUB print_talking_table,aisc_talking_functions_set_
117
118P int* (**aisc_talking_functions_find[])() = {
119GOSUB print_talking_table,aisc_talking_functions_find_
120
121P int* (**aisc_talking_functions_copy[])() = {
122GOSUB print_talking_table,aisc_talking_functions_copy_
123
124P talking_function* aisc_talking_functions_create[] = {
125GOSUB print_talking_table,aisc_talking_functions_create_
126
127P aisc_destroy_callback aisc_talking_functions_delete[] = {
128GOSUB print_talking_table_casted,destroy_,aisc_destroy_callback
129
130# FINISH
131P #undef __P
132CLOSE save
133EXIT
134
135# -----------------
136#     FUNCTIONS
137
138FUNCTION print_talking_table,name
139    CALL print_talking_table_casted,$(name),
140RETURN
141
142FUNCTION print_talking_table_casted,name,cast
143    GOSUB clearkeylist
144    FOR $(STRUCT)
145        IF $(SKEY)
146            IF $(cast)_ != _
147                SET $(key[$(SKEYC)]) = AISC_CASTSIG($(cast),$(name)$(STRUCT)),
148            ELSE
149                SET $(key[$(SKEYC)]) = $(name)$(STRUCT),
150            ENDIF
151        ENDIF
152    ENDFOR
153    GOSUB printkeylist
154    P $(termptrlist)
155RETURN
156
157FUNCTION make_attr_names
158    CREATE $(nr) = $(nummer)
159    CREATE $(s) = $(aisc_string)
160    FOR $({/TYPE)
161        IF $(KEY)
162            IF $(REF) ~ s
163                PUSH
164                SET $(nummer) = $(+ $(nr)+$(KEYC) )
165                SET $(aisc_string) = $(s)$(KEY)_
166                MOVETO $(/AISC/DATA/STRUCT.$(TYPE))
167                GOSUB make_attr_names
168                POP
169            ELSEIF $(REF) ~ d
170                SET $(key[$(+ $(+ $(nr)+1)+$(KEYC))])="$(s)$(KEY)CNT",
171                SET $(key[$(+ $(nr)+$(KEYC))]) = "$(s)$(KEY)",
172            ELSEIF $(TYPE) = dllh
173                PUSH
174                SET $(nummer) = $(+ 2+$(+ $(nr)+$(KEYC) ))
175                SET $(aisc_string) = $(s)$(KEY)
176                MOVETO $(/AISC/DATA/STRUCT.dll_header)
177                GOSUB make_attr_names
178                POP
179                SET $(key[$(+ $(nr)+0)]) = "$(s)PREVIOUS",
180                SET $(key[$(+ $(nr)+1)]) = "$(s)NEXT",
181            ELSE
182                SET $(key[$(+ $(nr)+$(KEYC))]) = "$(s)$(KEY)",
183            ENDIF
184        ENDIF
185    ENDFOR
186RETURN
187
188FUNCTION clearkeylist
189    FOR $(i) = 0 TO $(max_key)
190        SET $(key[$(i)]) = NULp,
191    ENDFOR
192RETURN
193FUNCTION clearobjlist
194    FOR $(i) = 0 TO $(max_obj)
195        SET $(obj[$(i)]) = NULp,
196    ENDFOR
197RETURN
198FUNCTION clearobjflaglist
199    FOR $(i) = 0 TO $(max_obj)
200        SET $(obj[$(i)]) = 0,
201    ENDFOR
202RETURN
203FUNCTION printkeylist
204    FOR $(i) = 0 TO $(max_key)
205        P $1$(key[$(i)])
206    ENDFOR
207RETURN
208FUNCTION printobjlist
209    FOR $(i) = 0 TO $(max_obj)
210        P $1$(obj[$(i)])
211    ENDFOR
212RETURN
213
Note: See TracBrowser for help on using the repository browser.