1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-04 18:29:19 +02:00

quick try at adding DC_EVENT names and use them to deltachat bindings

This commit is contained in:
holger krekel 2018-09-05 13:53:18 +02:00
parent eec2261cca
commit 0340dbe81c
3 changed files with 40 additions and 4 deletions

View file

@ -1,9 +1,27 @@
import distutils.ccompiler
import distutils.sysconfig
import tempfile
from os.path import dirname, abspath
from os.path import join as joinpath
import cffi
here = dirname(abspath(__file__))
deltah = joinpath(dirname(dirname(dirname(here))), "src", "deltachat.h")
def read_event_defines():
for line in open(deltah):
if line.startswith("#define"):
parts = line.split()
if len(parts) >= 3:
if parts[1].startswith("DC_EVENT"):
try:
val = int(parts[2])
except ValueError:
continue
yield line
def ffibuilder():
builder = cffi.FFI()
@ -35,6 +53,8 @@ def ffibuilder():
uintptr_t data1,
uintptr_t data2);
""")
event_defines = "\n".join(read_event_defines())
builder.cdef(event_defines)
return builder