ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/preprocess
(Generate patch)

Comparing deliantra/server/include/preprocess (file contents):
Revision 1.2 by root, Thu Aug 31 09:19:34 2006 UTC vs.
Revision 1.6 by root, Wed Sep 13 02:05:19 2006 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3use List::Util;
2 4
3# todo: gather dynamically 5# todo: gather dynamically
4my @kw = qw( 6my @kw = qw(
7 no_pass
8 walk_on
9 walk_off
10 fly_on
11 fly_off
12 flying
13
5 ac 14 ac
6 activate_on_push 15 activate_on_push
7 activate_on_release 16 activate_on_release
8 alive 17 alive
9 anim_speed 18 anim_speed
221 unaggressive 230 unaggressive
222 undead 231 undead
223 unique 232 unique
224 unpaid 233 unpaid
225 use_content_on_gen 234 use_content_on_gen
235 uuid
226 value 236 value
227 vulnerable 237 vulnerable
228 was_wiz 238 was_wiz
229 wc 239 wc
230 weapontype 240 weapontype
233 wis 243 wis
234 wiz 244 wiz
235 x 245 x
236 xrays 246 xrays
237 y 247 y
248
249 Object
250 Str
251 Dex
252 Con
253 Wis
254 Cha
255 Int
256 Pow
257 More
238); 258);
239 259
240open GPERF, "|-", "gperf -m50 >kw_hash.h" 260open GPERF, "|-", "gperf -m50 >kw_hash.h"
241 or die "gperf: $!"; 261 or die "gperf: $!";
242 262
251struct keyword_idx { const char *name; enum keyword index; }; 271struct keyword_idx { const char *name; enum keyword index; };
252%% 272%%
253EOF 273EOF
254 274
255for (@kw) { 275for (@kw) {
256 printf GPERF "%s,%s\n", $_, "KW_" . uc; 276 printf GPERF "%s,%s\n", $_, "KW_$_";
257} 277}
258 278
259print GPERF <<EOF; 279print GPERF <<EOF;
260%% 280%%
261const char *const keyword_str [] = { 281extern const char *const keyword_str [] = {
262 "<EOF>", 282 "<EOF>",
263 "<ERROR>", 283 "<ERROR>",
264EOF 284EOF
265 285
266for (@kw) { 286for (@kw) {
267 printf GPERF " \"%s\",\n", $_; 287 printf GPERF " \"%s\",\n", $_;
268} 288}
269 289
270print GPERF "};\n\n"; 290print GPERF "};\n";
291
292printf GPERF "\nextern const unsigned char keyword_len [] = { 5, 7, %s };\n\n",
293 join ", ", map length, @kw;
271 294
272open KW, ">", "keyword.h"; 295open KW, ">", "keyword.h";
273 296
274print KW <<EOF; 297print KW <<EOF;
275#ifndef KW_H__ 298#ifndef KW_H__
276#define KW_H__ 299#define KW_H__
277 300
278enum keyword { 301enum keyword {
279 KW_eof, KW_error, 302 KW_EOF, KW_ERROR,
280EOF 303EOF
281 304
282for (@kw) { 305for (@kw) {
283 printf KW " %s,\n", "KW_" . uc; 306 printf KW " %s,\n", "KW_$_",
284} 307}
285 308
286print KW <<EOF; 309print KW <<EOF;
287 NUM_KEYWORD, 310 NUM_KEYWORD,
288}; 311};
289 312
290extern const char *const keyword_str []; 313extern const char *const keyword_str [];
314extern const unsigned char keyword_len [];
315
316EOF
317
318printf KW "#define MAX_KEYWORD_LEN %d\n", List::Util::max map length, @kw;
319
320print KW <<EOF;
291 321
292#endif 322#endif
293 323
294EOF 324EOF
295 325

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines