aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-10-12 13:18:07 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-10-12 13:18:07 -0700
commit6206e1ee59d9d1abd9757d247a3f001b2dc5476a (patch)
treee7da4f92086773b4044b5eb9f1b604fb5806304d
parent5dd35ab0a3edf924e84afc65d0eebe8a80bfb17b (diff)
parent94efe72ab954d3894d571f745dcc86f9f917819f (diff)
downloadcryptography-6206e1ee59d9d1abd9757d247a3f001b2dc5476a.tar.gz
cryptography-6206e1ee59d9d1abd9757d247a3f001b2dc5476a.tar.bz2
cryptography-6206e1ee59d9d1abd9757d247a3f001b2dc5476a.zip
Merge pull request #99 from reaperhulk/cffi-load-types-first
Load types from all cffi modules before declaring functions or macros
-rw-r--r--cryptography/bindings/openssl/api.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py
index 129605f3..ed3576aa 100644
--- a/cryptography/bindings/openssl/api.py
+++ b/cryptography/bindings/openssl/api.py
@@ -41,16 +41,24 @@ class API(object):
self.ffi = cffi.FFI()
includes = []
functions = []
+ macros = []
for name in self._modules:
__import__("cryptography.bindings.openssl." + name)
module = sys.modules["cryptography.bindings.openssl." + name]
self.ffi.cdef(module.TYPES)
- self.ffi.cdef(module.FUNCTIONS)
- self.ffi.cdef(module.MACROS)
+ macros.append(module.MACROS)
functions.append(module.FUNCTIONS)
includes.append(module.INCLUDES)
+ # loop over the functions & macros after declaring all the types
+ # so we can set interdependent types in different files and still
+ # have them all defined before we parse the funcs & macros
+ for func in functions:
+ self.ffi.cdef(func)
+ for macro in macros:
+ self.ffi.cdef(macro)
+
# We include functions here so that if we got any of their definitions
# wrong, the underlying C compiler will explode. In C you are allowed
# to re-declare a function if it has the same signature. That is: