1 %module marisa 2 3 %include "cstring.i" 4 %include "exception.i" 5 6 %{ 7 #include "marisa-swig.h" 8 %} 9 10 %apply (char *STRING, int LENGTH) { (const char *ptr, std::size_t length) }; 11 12 %cstring_output_allocate_size(const char **ptr_out, std::size_t *length_out, ); 13 %cstring_output_allocate_size(const char **ptr_out_to_be_deleted, 14 std::size_t *length_out, delete [] (*$1)); 15 16 %exception { 17 try { 18 $action catch(const marisa::Exception & ex)19 } catch (const marisa::Exception &ex) { 20 SWIG_exception(SWIG_RuntimeError, ex.what()); 21 } catch (...) { 22 SWIG_exception(SWIG_UnknownError,"Unknown exception"); 23 } 24 } 25 26 %include "marisa-swig.h" 27 28 %constant size_t INVALID_KEY_ID = MARISA_INVALID_KEY_ID; 29