CBL-Mariner/SPECS-EXTENDED/libchewing/0001-chewing.py-supports-pl...

42 строки
1.4 KiB
Diff

From 9025eeb2bf2cba851073cb4178fd71f71c74391d Mon Sep 17 00:00:00 2001
From: Robin Lee <cheeselee@fedoraproject.org>
Date: Thu, 8 Aug 2019 17:16:21 +0800
Subject: [PATCH] chewing.py supports platforms with 64bit pointer
The old code will segfault on platforms with 64bit pointer like x86_64.
---
contrib/python/chewing.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/contrib/python/chewing.py b/contrib/python/chewing.py
index a9f17ec..acf000b 100644
--- a/contrib/python/chewing.py
+++ b/contrib/python/chewing.py
@@ -19,6 +19,8 @@ _libchewing.chewing_cand_String.restype = c_char_p
_libchewing.chewing_zuin_String.restype = c_char_p
_libchewing.chewing_aux_String.restype = c_char_p
_libchewing.chewing_get_KBString.restype = c_char_p
+_libchewing.chewing_new.restype = c_void_p
+_libchewing.chewing_new2.restype = c_void_p
def Init(datadir, userdir):
@@ -39,12 +41,12 @@ class ChewingContext:
None)
def __del__(self):
- _libchewing.chewing_delete(self.ctx)
+ _libchewing.chewing_delete(c_void_p(self.ctx))
def __getattr__(self, name):
func = 'chewing_' + name
if hasattr(_libchewing, func):
- wrap = partial(getattr(_libchewing, func), self.ctx)
+ wrap = partial(getattr(_libchewing, func), c_void_p(self.ctx))
setattr(self, name, wrap)
return wrap
else:
--
2.21.0