comparison python/pydc/examples/atoi.py @ 48:a2125195b052

added callconv switching to one example
author Tassilo Philipp
date Fri, 13 Nov 2020 18:27:09 +0100
parents edbbd467f50a
children
comparison
equal deleted inserted replaced
47:44045db8fa5f 48:a2125195b052
14 else: 14 else:
15 libc = load("/lib/libc.so.6") 15 libc = load("/lib/libc.so.6")
16 16
17 fp_atoi = find(libc,"atoi") 17 fp_atoi = find(libc,"atoi")
18 fp_atof = find(libc,"atof") 18 fp_atof = find(libc,"atof")
19 fp_printf = find(libc,"printf")
19 20
20 21
21 22
22 def atoi(s): return call(fp_atoi,"Z)i",s) 23 def atoi(s): return call(fp_atoi,"Z)i",s)
23 def atod(s): return call(fp_atof,"Z)d",s) 24 def atod(s): return call(fp_atof,"Z)d",s)
24 25
25 print(atoi("3".join(["12","45"]))) 26 print(atoi("3".join(["12","45"])))
26 print(atod("3".join(["12","45"]))) 27 print(atod("3".join(["12","45"])))
27 28
29 # w/ some text - tests vararg callconv switch
30 call(fp_printf,"_eZ_.id)i", "and again: %d %f\n", atoi("31245"), atod("31245"))
31