annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 from pydc import *
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2 from sys import platform
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 if platform == "win32":
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 libc = load("msvcrt")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 elif platform == "darwin":
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 libc = load("/usr/lib/libc.dylib")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 else:
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
9 libc = load("/lib/libc.so.6")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11 fp_atoi = find(libc,"atoi")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 fp_atof = find(libc,"atof")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 def atoi(s): return call(fp_atoi,"p)i",s)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15 def atod(s): return call(fp_atof,"p)d",s)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 print atoi( "3".join(["12","45"]) )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 print atod( "3".join(["12","45"]) )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19