|
From: かいお (Kaio) <ca...@de...> - 2008-12-08 07:55:07
|
Hi,
Nice to meet you. My name is Caius from I18N team, Red Hat.
I am currently developing a module on ibus, a multi-language input
method platform. However, since the library (libtranslate) I am reusing
is written in C but ibus is written in Python, I tried to use swig to
wrap the libraryrecommended by ibus author.
My question is, I have a C method which its return data type is char*,
and I want the string to be passed to something written in Python. I
have created the interface .i file which is like:
===BEGIN .i file
%module trans_bridge
%include typemaps.i
#include <translate.h>
extern char *translate(char *from, char *to, char *text);
===END .i file
I proved the return of the method 'translate()' is valid as a char*
string by a 'main()' method in the same .c file.
Then I have the Python .py as follows:
===BEGIN .py file
...
import trans_bridge
...
def __commit_string(self, text):
self.__reset()
translated_text = trans_bridge.translate("en", "ja", text)
self.commit_string(translated_text)
self.__invalidate()
...
===END .py file
I checked the translated_text after the trans_beidge() is called. There
was no data be assigned.
I am wondering if I am implementing the char* passing correctly? Do I
need to do some extra codes because I have not found info about passing
char*.
Thank you very much.
Best Regards,
Caius.
-- Caius Chance, Soft Eng, I18N, Red Hat APAC, cchance AT redhat DOT com
JP (Qual), RHCE, MCSE, CCNA, JLPT4, http://apac.redhat.com/disclaimer
|