Mercurial > pub > dyncall > bindings
diff python/pydc/examples/atoi.py @ 0:0cfcc391201f
initial from svn dyncall-1745
author | Daniel Adler |
---|---|
date | Thu, 19 Mar 2015 22:26:28 +0100 |
parents | |
children | bf5625bb6f05 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/pydc/examples/atoi.py Thu Mar 19 22:26:28 2015 +0100 @@ -0,0 +1,19 @@ +from pydc import * +from sys import platform + +if platform == "win32": + libc = load("msvcrt") +elif platform == "darwin": + libc = load("/usr/lib/libc.dylib") +else: + libc = load("/lib/libc.so.6") + +fp_atoi = find(libc,"atoi") +fp_atof = find(libc,"atof") + +def atoi(s): return call(fp_atoi,"p)i",s) +def atod(s): return call(fp_atof,"p)d",s) + +print atoi( "3".join(["12","45"]) ) +print atod( "3".join(["12","45"]) ) +