Commits

Armin Rigo  committed ef7317d

Rename ffi.rawload() to ffi.dlopen().

  • Participants
  • Parent commits dc76fa4

Comments (0)

Files changed (5)

             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
 
     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
         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

File demo/readdir.py

     int closedir(DIR *dirp);
 
 """)
-ffi.C = ffi.rawload(None)
+ffi.C = ffi.dlopen(None)
 
 
 

File testing/test_function.py

         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)
 
         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
             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")
             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")
             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()
            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"))
         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)")
         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:
             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 *)'>"
         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
             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 *'>"
         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!"
             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'

File testing/test_ownlib.py

         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
         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

File testing/test_parsing.py

 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>'
 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>'
 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>'
     ffi.cdef("""
         int foo(void);
         """)
-    C = ffi.rawload(None)
+    C = ffi.dlopen(None)
     assert C.foo.BType == '<func (), <int>, False>'
 
 def test_typedef():
         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>'
 
         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 '
         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>'