Commits

Leonard Ritter committed 490e378

support for binding to local code only

  • Participants
  • Parent commits 0142cd6

Comments (0)

Files changed (1)

autobind/__init__.py

 
     def test_cdefs(self,cdefs,hdefs):
         options = self.options
-        LIBNAME = options['LIBNAME']
+        LIBNAME = options.get('LIBNAME',None)
+        DEF_VERIFY_OPTIONS = dict(
+        )
+        
+        if LIBNAME:
+            DEF_VERIFY_OPTIONS['libraries'] = [LIBNAME]
+
         VERIFY_SOURCE = options.get('VERIFY_SOURCE', hdefs)
-        VERIFY_OPTIONS = options.get('VERIFY_OPTIONS', dict(
-            libraries = [LIBNAME],
-        ))
+        VERIFY_OPTIONS = options.get('VERIFY_OPTIONS', DEF_VERIFY_OPTIONS)
         
         ffi = FFI()
         ffi.cdef(cdefs)
         capi = ffi.verify(VERIFY_SOURCE, 
             **VERIFY_OPTIONS)
         # crosscheck
-        dlffi = FFI()
-        dlffi.cdef(cdefs)
-        dlcapi = dlffi.dlopen(LIBNAME)
         outcapi = {}
+        if LIBNAME:
+            dlffi = FFI()
+            dlffi.cdef(cdefs)
+            dlcapi = dlffi.dlopen(LIBNAME)
+        else:
+            dlffi = ffi
+            dlcapi = capi
         for name,value in capi.__dict__.items():
             if name.startswith('__'):
                 print("skipping",name)
                 dlvalue = getattr(dlcapi, name)
                 outcapi[name] = dlvalue
             elif isinstance(value, (int,float,long)):
-                assert not hasattr(dlcapi, name)
                 outcapi[name] = value
             else:
                 print("ignoring",name,value)