Mercurial > pub > dyncall > dyncall
comparison test/suite_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 import sys | |
22 | |
23 # parameters | |
24 | |
25 nargs = 3 | |
26 | |
27 types = ["DCbool","DCint","DClonglong","DCdouble","DCpointer","DCfloat"] | |
28 | |
29 # generator | |
30 | |
31 ntypes = len(types) | |
32 | |
33 sys.stderr.write("/* auto generated by mkcase (on stderr) */\n"); | |
34 sys.stderr.write("".join(["#define NARGS ",str(nargs),"\n"])) | |
35 sys.stderr.write("".join(["#define NTYPES ",str(ntypes),"\n"])) | |
36 | |
37 def powerfact(x, n): | |
38 if n==0: | |
39 return 0 | |
40 else: | |
41 return x**n+powerfact(x,n-1) | |
42 | |
43 x = 0 | |
44 end = powerfact(ntypes,nargs)+1 | |
45 | |
46 sys.stdout.write("/* auto generated by mkcase.py (on stdout) */\n"); | |
47 | |
48 while x < end: | |
49 args = [str(x)] | |
50 sig = ["f_"] | |
51 pos = 0 | |
52 y = x | |
53 while y > 0: | |
54 s = (y-1) % ntypes | |
55 y = (y-1) / ntypes | |
56 args += [ types[s] ] | |
57 sig += [ types[s][2] ] | |
58 pos += 1 | |
59 sig = "".join(sig) | |
60 args += [ sig ] | |
61 args = ",".join(args) | |
62 sys.stdout.write( "".join(["VF",str(pos),"(",args,")\n"]) ) | |
63 x += 1 | |
64 |