%init %{
%}
+
%typemap (in) ucschar * {
if (PyUnicode_Check ($input)) {
$1 = PyUnicode_AsUnicode ($input);
}
}
+/* define exception */
+%exception {
+ $action
+ if (PyErr_Occurred ()) {
+ return NULL;
+ }
+}
+
typedef int ucschar;
/* define struct HangulKeyboard */
typedef struct {} HanjaTable;
%extend HanjaTable {
HanjaTable (const char *name) {
- return hanja_table_load (name);
+ HanjaTable *table = hanja_table_load (name);
+ if (table == NULL) {
+ PyErr_Format (PyExc_IOError,
+ "Can not load HanjaTabel from %s.", name);
+ return NULL;
+ }
+ return table;
}
~HanjaTable () {