Dear all,
回應 czchen 以及增加二個 issue
>> 像 chewing_get_KBString 沒有 static 版本,設 .restype = c_char_p 看不出 runtime error
>> 但是 python 裡面並沒有 call chewing_free 如說明文件所指示的,會不會導致 memory leak?
> 會造成 memory leak。這裡應該要用 static API。
>
>>
>> 2. chewing_bopomofo_String_static 沒找到對應之 non-static 版本,各位覺得是否也要補回去?
>
> No
>
> 如果使用者需要 non-static,可以直接用 strdup(chewing_bopomofo_String_static)。
依照現行 chewing.py 寫法,全部都 call non-static API... 這樣說來就全部都是 memory leak...
如果對 non-static API 的需求全部都建議用 strdup 取代,以後是否要將 static 的分別除去,只要給 const
char* 版本的 API 就好?
(不過這很大改變,幾乎整個 .h 和文件都要整修...)
Issues:
1.
chewing.py 用 __dict__ 檢驗 attribute 存在,根據 [0] 這方法 generally speaking
是不大正確的,我想建議改為 hasattr+getattr 的方式來檢驗 (see patch)
2.
用 chewing.dll 當預設的 dll name, 想請教 mingw 編譯出來該如何讓檔名是 chewing.dll?
目前 cmake+mingw 的產品為 libchewing.dll
Thanks!
[0]
http://stackoverflow.com/questions/9748678/which-is-the-best-way-to-check-for-the-existence-of-an-attribute