Closed cr-marcstevens closed 6 years ago
What Python objects should the function expect and accept?
Well, not sure what the exact type is, but I'd like this code to work:
import ctypes
enumlib = ctypes.cdll.LoadLibrary("../enumlib/enumlib.so")
fpylll.set_external_enumerator(enumlib.enumlib_enumerate)
See also https://github.com/cr-marcstevens/fplll-extenum/blob/master/lib/enumlib.hpp
I've started to look into this, have you used ctypes for this successfully? I'm hitting two roadblocks:
C++ name mangling means that enumlib.enumlib_enumerate
won't work. But
enumlib_enumerate = enumlib._Z17enumlib_enumerateidSt8functionIFvPdmbS0_S0_EES_IFddS0_EES_IFvdS0_iEEbb
does the trick.
I'm having a hard time convincing the compiler to accept some, say, void*
as a parameter for set_external_enumerator
I guess I could hack around it by using ctypes
for set_external_enumerator
as well, instead of mixing Cython and Ctypes. It'd be nice to have a cleaner solution, though.
Note that e.g. https://github.com/cr-marcstevens/fplll-extenum has now more convenient usage:
import ctypes
enumlib = ctypes.cdll.LoadLibrary("libfplll_enumlib.so")
enumlib.fplll_register_enumlib()
This is a C interface, so it has no C++ name mangling, and is therefore easier and more robust to use from python.
To activate an external enumeration library we need this function exposed in fpylll.
https://github.com/fplll/fplll/blob/master/fplll/enum/enumerate_ext.h#L80 : set_external_enumerator