forked from chokkan/crfsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.i
47 lines (39 loc) · 1.05 KB
/
export.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#if defined(SWIGPERL)
%module(directors="1") CRFSuite
#else
%module(directors="1") crfsuite
#endif
%{
#include "crfsuite_api.hpp"
%}
%include "std_string.i"
%include "std_vector.i"
%include "exception.i"
#ifdef SWIGPERL
// PERL5 Scalar value -> STL std::string
%typemap(in) const std::string& ($basetype temp) {
STRLEN len;
char *s = SvPV($input, len);
temp.assign(s, len);
$1 = &temp;
}
%typemap(freearg) const std::string& ""
#endif
%template(Item) std::vector<CRFSuite::Attribute>;
%template(ItemSequence) std::vector<CRFSuite::Item>;
%template(StringList) std::vector<std::string>;
%feature("director") Trainer;
%exception {
try {
$action
} catch(const std::invalid_argument& e) {
SWIG_exception(SWIG_IOError, e.what());
} catch(const std::runtime_error& e) {
SWIG_exception(SWIG_RuntimeError, e.what());
} catch (const std::exception& e) {
SWIG_exception(SWIG_RuntimeError, e.what());
} catch(...) {
SWIG_exception(SWIG_RuntimeError,"Unknown exception");
}
}
%include "crfsuite_api.hpp"