comparison test/suite2_x86win32fast/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
22 import sys
23
24 f = file("design.cfg")
25
26 sigmap = {
27 'B':'DCbool'
28 , 'c':'DCchar'
29 , 's':'DCshort'
30 , 'i':'DCint'
31 , 'l':'DClonglong'
32 , 'f':'DCfloat'
33 , 'd':'DCdouble'
34 , 'p':'DCpointer'
35 }
36
37 apimap = {
38 '_':''
39 , 's':'__declspec(stdcall)'
40 , 'f':'__declspec(fastcall)'
41 }
42
43 id = 0
44 maxargs = 0
45 sys.stdout.write("/* auto generated by mkcase.py (on stdout) */\n");
46 for line in f:
47 line = line.rstrip().lstrip()
48 if len(line) == 0 or line[0] == '#': continue
49 types = [];
50 # args = len(line)-1
51 args = len(line)
52 maxargs = max(maxargs, args)
53 # api = apimap[ line[0] ]
54 out = [ "VF",str(args),"(", str(id), "," ];
55 for i in xrange(0,len(line)):
56 types += [ sigmap[ line[i] ] ]
57 out += [ ",".join( types ), ",s_", line, ")\n" ]
58 out = "".join(out)
59 sys.stdout.write(out)
60 id += 1
61
62 sys.stderr.write("/* auto generated by mkcase (on stderr) */\n");
63 sys.stderr.write("".join( ["#define NCASES ",str(id),"\n"] ) )
64 sys.stderr.write("".join( ["#define MAXARGS ",str(maxargs),"\n"] ) )
65
66
67