aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cryptography/bindings/openssl/api.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py
index 129605f3..f7e14c10 100644
--- a/cryptography/bindings/openssl/api.py
+++ b/cryptography/bindings/openssl/api.py
@@ -17,6 +17,8 @@ import sys
import cffi
+import six
+
from cryptography.primitives import interfaces
@@ -41,16 +43,23 @@ 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, macro in six.moves.zip(functions, macros):
+ self.ffi.cdef(func)
+ 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: