Mercurial > pub > dyncall > dyncall
comparison test/suite2_x86win32std/mkcase.py @ 0:3e629dc19168
initial from svn dyncall-1745
author | Daniel Adler |
---|---|
date | Thu, 19 Mar 2015 22:24:28 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3e629dc19168 |
---|---|
1 #!/usr/bin/python | |
2 #////////////////////////////////////////////////////////////////////////////// | |
3 # | |
4 # Copyright (c) 2007,2009 Daniel Adler <dadler@uni-goettingen.de>, | |
5 # Tassilo Philipp <tphilipp@potion-studios.com> | |
6 # | |
7 # Permission to use, copy, modify, and distribute this software for any | |
8 # purpose with or without fee is hereby granted, provided that the above | |
9 # copyright notice and this permission notice appear in all copies. | |
10 # | |
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
18 # | |
19 #////////////////////////////////////////////////////////////////////////////// | |
20 | |
21 import sys | |
22 | |
23 f = file("design.cfg") | |
24 | |
25 sigmap = { | |
26 'B':'DCbool' | |
27 , 'c':'DCchar' | |
28 , 's':'DCshort' | |
29 , 'i':'DCint' | |
30 , 'l':'DClonglong' | |
31 , 'f':'DCfloat' | |
32 , 'd':'DCdouble' | |
33 , 'p':'DCpointer' | |
34 } | |
35 | |
36 apimap = { | |
37 '_':'' | |
38 , 's':'__declspec(stdcall)' | |
39 , 'f':'__declspec(fastcall)' | |
40 } | |
41 | |
42 id = 0 | |
43 maxargs = 0 | |
44 sys.stdout.write("/* auto generated by mkcase.py (on stdout) */\n"); | |
45 for line in f: | |
46 line = line.rstrip().lstrip() | |
47 if len(line) == 0 or line[0] == '#': continue | |
48 types = []; | |
49 # args = len(line)-1 | |
50 args = len(line) | |
51 maxargs = max(maxargs, args) | |
52 # api = apimap[ line[0] ] | |
53 out = [ "VF",str(args),"(", str(id), "," ]; | |
54 for i in xrange(0,len(line)): | |
55 types += [ sigmap[ line[i] ] ] | |
56 out += [ ",".join( types ), ",s_", line, ")\n" ] | |
57 out = "".join(out) | |
58 sys.stdout.write(out) | |
59 id += 1 | |
60 | |
61 sys.stderr.write("/* auto generated by mkcase (on stderr) */\n"); | |
62 sys.stderr.write("".join( ["#define NCASES ",str(id),"\n"] ) ) | |
63 sys.stderr.write("".join( ["#define MAXARGS ",str(maxargs),"\n"] ) ) | |
64 | |
65 | |
66 |