[pypy-commit] cffi default: Rename ffi.rawload() to ffi.dlopen().
arigo
noreply at buildbot.pypy.org
Thu Jun 14 16:33:00 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r341:ef7317d3c21c
Date: 2012-06-14 16:32 +0200
http://bitbucket.org/cffi/cffi/changeset/ef7317d3c21c/
Log: Rename ffi.rawload() to ffi.dlopen().
diff --git a/cffi/api.py b/cffi/api.py
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -23,7 +23,7 @@
int printf(const char *, ...);
""")
- C = ffi.rawload(name=None) # standard library
+ C = ffi.dlopen(None) # standard library
-or-
C = ffi.verify() # use a C compiler: verify the decl above is right
@@ -68,12 +68,12 @@
def cdef(self, csource):
"""Parse the given C source. This registers all declared functions,
types, and global variables. The functions and global variables can
- then be accessed via 'ffi.rawload()'. The types can be used
- in 'ffi.new()' and other functions.
+ then be accessed via either 'ffi.dlopen()' or 'ffi.verify()'.
+ The types can be used in 'ffi.new()' and other functions.
"""
self._parser.parse(csource)
- def rawload(self, name):
+ def dlopen(self, name):
"""Load and return a dynamic library identified by 'name'.
The standard C library can be loaded by passing None.
Note that functions and types declared by 'ffi.cdef()' are not
@@ -190,7 +190,7 @@
library can be used to call functions and access global
variables declared in this 'ffi'. The library is compiled
by the C compiler: it gives you C-level API compatibility
- (including calling macros). This is unlike 'ffi.rawload()',
+ (including calling macros). This is unlike 'ffi.dlopen()',
which requires binary compatibility in the signatures.
"""
from .verifier import Verifier
diff --git a/demo/readdir.py b/demo/readdir.py
--- a/demo/readdir.py
+++ b/demo/readdir.py
@@ -25,7 +25,7 @@
int closedir(DIR *dirp);
""")
-ffi.C = ffi.rawload(None)
+ffi.C = ffi.dlopen(None)
diff --git a/testing/test_function.py b/testing/test_function.py
--- a/testing/test_function.py
+++ b/testing/test_function.py
@@ -36,7 +36,7 @@
ffi.cdef("""
double sin(double x);
""")
- m = ffi.rawload("m")
+ m = ffi.dlopen("m")
x = m.sin(1.23)
assert x == math.sin(1.23)
@@ -45,7 +45,7 @@
ffi.cdef("""
float sinf(float x);
""")
- m = ffi.rawload("m")
+ m = ffi.dlopen("m")
x = m.sinf(1.23)
assert type(x) is float
assert x != math.sin(1.23) # rounding effects
@@ -57,7 +57,7 @@
int puts(const char *);
int fflush(void *);
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
ffi.C.puts # fetch before capturing, for easier debugging
with FdWriteCapture() as fd:
ffi.C.puts("hello")
@@ -72,7 +72,7 @@
int puts(char *);
int fflush(void *);
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
ffi.C.puts # fetch before capturing, for easier debugging
with FdWriteCapture() as fd:
ffi.C.puts("hello")
@@ -87,7 +87,7 @@
int fputs(const char *, void *);
void *stdout, *stderr;
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
with FdWriteCapture(2) as fd:
ffi.C.fputs("hello from stderr\n", ffi.C.stderr)
res = fd.getvalue()
@@ -99,7 +99,7 @@
int printf(const char *format, ...);
int fflush(void *);
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
with FdWriteCapture() as fd:
ffi.C.printf("hello with no arguments\n")
ffi.C.printf("hello, %s!\n", ffi.new("char[]", "world"))
@@ -123,7 +123,7 @@
ffi.cdef("""
int printf(const char *format, ...);
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
e = py.test.raises(TypeError, ffi.C.printf, "hello %d\n", 42)
assert str(e.value) == ("argument 2 passed in the variadic part "
"needs to be a cdata object (got int)")
@@ -133,7 +133,7 @@
ffi.cdef("""
int puts(const char *);
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
fptr = ffi.C.puts
assert ffi.typeof(fptr) == ffi.typeof("int(*)(const char*)")
if self.Backend is CTypesBackend:
@@ -154,7 +154,7 @@
int puts(const char *);
int fflush(void *);
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
fptr = ffi.cast("int(*)(const char *txt)", ffi.C.puts)
assert fptr == ffi.C.puts
assert repr(fptr) == "<cdata 'int(*)(char *)'>"
@@ -169,7 +169,7 @@
ffi.cdef("""
int strlen(char[]);
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
p = ffi.new("char[]", "hello")
res = ffi.C.strlen(p)
assert res == 5
@@ -180,7 +180,7 @@
int puts(const char *);
void *stdout, *stderr;
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
pout = ffi.C.stdout
perr = ffi.C.stderr
assert repr(pout) == "<cdata 'void *'>"
@@ -199,7 +199,7 @@
ffi.cdef("""
char *strchr(const char *s, int c);
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
p = ffi.new("char[]", "hello world!")
q = ffi.C.strchr(p, ord('w'))
assert str(q) == "world!"
@@ -210,7 +210,7 @@
struct in_addr { unsigned int s_addr; };
char *inet_ntoa(struct in_addr in);
""")
- ffi.C = ffi.rawload(None)
+ ffi.C = ffi.dlopen(None)
ina = ffi.new("struct in_addr", [0x04040404])
a = ffi.C.inet_ntoa(ina[0])
assert str(a) == '4.4.4.4'
diff --git a/testing/test_ownlib.py b/testing/test_ownlib.py
--- a/testing/test_ownlib.py
+++ b/testing/test_ownlib.py
@@ -33,8 +33,8 @@
ffi.cdef("""
int test_getting_errno(void);
""")
- ownlib = ffi.rawload(self.module)
- C = ffi.rawload(None)
+ ownlib = ffi.dlopen(self.module)
+ C = ffi.dlopen(None)
res = ownlib.test_getting_errno()
assert res == -1
assert C.errno == 123
@@ -46,8 +46,8 @@
ffi.cdef("""
int test_setting_errno(void);
""")
- ownlib = ffi.rawload(self.module)
- C = ffi.rawload(None)
+ ownlib = ffi.dlopen(self.module)
+ C = ffi.dlopen(None)
C.errno = 42
res = ownlib.test_setting_errno()
assert res == 42
diff --git a/testing/test_parsing.py b/testing/test_parsing.py
--- a/testing/test_parsing.py
+++ b/testing/test_parsing.py
@@ -53,7 +53,7 @@
def test_simple():
ffi = FFI(backend=FakeBackend())
ffi.cdef("double sin(double x);")
- m = ffi.rawload("m")
+ m = ffi.dlopen("m")
func = m.sin # should be a callable on real backends
assert func.name == 'sin'
assert func.BType == '<func (<double>), <double>, False>'
@@ -61,7 +61,7 @@
def test_pipe():
ffi = FFI(backend=FakeBackend())
ffi.cdef("int pipe(int pipefd[2]);")
- C = ffi.rawload(None)
+ C = ffi.dlopen(None)
func = C.pipe
assert func.name == 'pipe'
assert func.BType == '<func (<pointer to <int>>), <int>, False>'
@@ -69,7 +69,7 @@
def test_vararg():
ffi = FFI(backend=FakeBackend())
ffi.cdef("short foo(int, ...);")
- C = ffi.rawload(None)
+ C = ffi.dlopen(None)
func = C.foo
assert func.name == 'foo'
assert func.BType == '<func (<int>), <short>, True>'
@@ -79,7 +79,7 @@
ffi.cdef("""
int foo(void);
""")
- C = ffi.rawload(None)
+ C = ffi.dlopen(None)
assert C.foo.BType == '<func (), <int>, False>'
def test_typedef():
@@ -89,7 +89,7 @@
typedef UInt UIntReally;
UInt foo(void);
""")
- C = ffi.rawload(None)
+ C = ffi.dlopen(None)
assert ffi.typeof("UIntReally") == '<unsigned int>'
assert C.foo.BType == '<func (), <unsigned int>, False>'
@@ -99,7 +99,7 @@
typedef struct { int a, b; } foo_t, *foo_p;
int foo(foo_p[]);
""")
- C = ffi.rawload(None)
+ C = ffi.dlopen(None)
assert str(ffi.typeof("foo_t")) == '<int>a, <int>b'
assert ffi.typeof("foo_p") == '<pointer to <int>a, <int>b>'
assert C.foo.BType == ('<func (<pointer to <pointer to '
@@ -135,7 +135,7 @@
x, double/*several*//*comment*/y) /*on the same line*/
;
""")
- m = ffi.rawload("m")
+ m = ffi.dlopen("m")
func = m.sin
assert func.name == 'sin'
assert func.BType == '<func (<double>, <double>), <double>, False>'
More information about the pypy-commit
mailing list