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