Skip to content

Commit

Permalink
make constants local to XCFFIB so they don’t clash
Browse files Browse the repository at this point in the history
modules which depend on this may require their own version of the same mechanism
  • Loading branch information
georgeharker committed Dec 7, 2024
1 parent 033da74 commit 6af8cda
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
try:
# Note in ABI mode lib will be missing
from _xcffib import ffi, lib
assert lib.__CFFI_MODE == lib.__CFFI_MODE_API
assert lib.__XCFFIB_CFFI_MODE == lib.__XCFFIB_CFFI_MODE_API
cffi_mode = "API"
except ImportError:
try:
Expand All @@ -51,9 +51,9 @@
if soname is None:
soname = "libxcb.so"
lib = ffi.dlopen(soname) # noqa
if lib.__CFFI_MODE == lib.__CFFI_MODE_ABI:
if lib.__XCFFIB_CFFI_MODE == lib.__XCFFIB_CFFI_MODE_ABI:
cffi_mode = "ABI"
elif lib.__CFFI_MODE == lib.__CFFI_MODE_ABI_PRECOMPILED:
elif lib.__XCFFIB_CFFI_MODE == lib.__XCFFIB_CFFI_MODE_ABI_PRECOMPILED:
cffi_mode = "ABI(precompiled)"

__xcb_proto_version__ = 'placeholder'
Expand Down
20 changes: 10 additions & 10 deletions module/ffi_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@
__CFFI_MODE_ABI = 1
__CFFI_MODE_ABI_PRECOMPILED = 2
CDEF += f"""
#define __CFFI_MODE_API {__CFFI_MODE_API}
#define __CFFI_MODE_ABI {__CFFI_MODE_ABI}
#define __CFFI_MODE_ABI_PRECOMPILED {__CFFI_MODE_ABI_PRECOMPILED}
#define __XCFFIB_CFFI_MODE_API {__CFFI_MODE_API}
#define __XCFFIB_CFFI_MODE_ABI {__CFFI_MODE_ABI}
#define __XCFFIB_CFFI_MODE_ABI_PRECOMPILED {__CFFI_MODE_ABI_PRECOMPILED}
"""


Expand All @@ -265,7 +265,7 @@ def ffi_build():
try:
ffi = FFI()
ffi.cdef(CDEF + f"""
#define __CFFI_MODE {__CFFI_MODE_API}
#define __XCFFIB_CFFI_MODE {__CFFI_MODE_API}
""")

ffi.set_source_pkgconfig(
Expand All @@ -277,10 +277,10 @@ def ffi_build():
#include "xcb/xcbext.h"
#include "xcb/render.h"
""" + f"""
#define __CFFI_MODE_API {__CFFI_MODE_API}
#define __CFFI_MODE_ABI {__CFFI_MODE_ABI}
#define __CFFI_MODE_ABI_PRECOMPILED {__CFFI_MODE_ABI_PRECOMPILED}
#define __CFFI_MODE {__CFFI_MODE_API}
#define __XCFFIB_CFFI_MODE_API {__CFFI_MODE_API}
#define __XCFFIB_CFFI_MODE_ABI {__CFFI_MODE_ABI}
#define __XCFFIB_CFFI_MODE_ABI_PRECOMPILED {__CFFI_MODE_ABI_PRECOMPILED}
#define __XCFFIB_CFFI_MODE {__CFFI_MODE_API}
"""
)

Expand All @@ -290,7 +290,7 @@ def ffi_build():
warn("Falling back to precompiled python mode")
ffi = FFI()
ffi.cdef(CDEF + f"""
#define __CFFI_MODE {__CFFI_MODE_ABI_PRECOMPILED}
#define __XCFFIB_CFFI_MODE {__CFFI_MODE_ABI_PRECOMPILED}
""")

ffi.set_source(
Expand All @@ -303,7 +303,7 @@ def ffi_build():

ffi = FFI()
ffi.cdef(CDEF + f"""
#define __CFFI_MODE {__CFFI_MODE_ABI}
#define __XCFFIB_CFFI_MODE {__CFFI_MODE_ABI}
""")


Expand Down

0 comments on commit 6af8cda

Please sign in to comment.