Mercurial > pub > dyncall > dyncall
comparison test/suite/mkcase.py @ 0:3e629dc19168
initial from svn dyncall-1745
author | Daniel Adler |
---|---|
date | Thu, 19 Mar 2015 22:24:28 +0100 |
parents | |
children | 74a4f682d1ef |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3e629dc19168 |
---|---|
1 #!/usr/bin/python | |
2 #////////////////////////////////////////////////////////////////////////////// | |
3 # | |
4 # Copyright (c) 2007,2011 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 = 8 | |
26 | |
27 #TODO: enable all types. temporary disabled for debuggin sparc64. | |
28 types = ["DCdouble","DClonglong"]#,"DCint","DCpointer","DCbool"]#,"DCfloat"] | |
29 typeSigs = ["d" ,"l" ]#,"i" ,"p" ,"B" ]#,"f" ] | |
30 | |
31 # generator | |
32 | |
33 ntypes = len(types) | |
34 | |
35 sys.stderr.write("/* auto generated by mkcase (on stderr) */\n"); | |
36 sys.stderr.write("".join(["#define NARGS ",str(nargs),"\n"])) | |
37 sys.stderr.write("".join(["#define NTYPES ",str(ntypes),"\n"])) | |
38 | |
39 def powerfact(x, n): | |
40 if n==0: | |
41 return 0 | |
42 else: | |
43 return x**n+powerfact(x,n-1) | |
44 | |
45 x = 0 | |
46 end = powerfact(ntypes,nargs)+1 | |
47 | |
48 sys.stdout.write("/* auto generated by mkcase.py (on stdout) */\n"); | |
49 | |
50 while x < end: | |
51 args = [str(x)] | |
52 sig = ["f_"] | |
53 pos = 0 | |
54 y = x | |
55 while y > 0: | |
56 s = (y-1) % ntypes | |
57 y = (y-1) / ntypes | |
58 args += [ types [s] ] | |
59 sig += [ typeSigs[s] ] | |
60 pos += 1 | |
61 sig = "".join(sig) | |
62 args += [ sig ] | |
63 args = ",".join(args) | |
64 sys.stdout.write( "".join(["VF",str(pos),"(",args,")\n"]) ) | |
65 x += 1 | |
66 |