-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathcommon.i
More file actions
73 lines (63 loc) · 1.69 KB
/
common.i
File metadata and controls
73 lines (63 loc) · 1.69 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
%include <std_pair.i>
%include <std_vector.i>
%include <std_string.i>
%include <std_except.i>
%include <exception.i>
%include <typemaps.i>
namespace std {
%template(StringVector) vector<string>;
}
%{
#include "sequenceParser/common.hpp"
#include <boost/filesystem/operations.hpp>
%}
namespace sequenceParser {
typedef long int Time;
}
%exception {
try
{
$action
}
catch (boost::filesystem::filesystem_error& e)
{
std::string message;
message = e.code().message() + " : ";
if (!e.path1().empty())
message += e.path1().string() + ".";
if (!e.path2().empty())
message += " " + e.path2().string();
SWIG_exception( SWIG_IOError, message.c_str() );
}
catch (std::exception& e)
{
SWIG_exception( SWIG_RuntimeError, e.what() );
}
catch( ... )
{
// Add the C++ backtrace into the exception log.
SWIG_exception( SWIG_RuntimeError, "[sequence parser] unknown error" );
}
}
#ifdef SWIGJAVA
// Define some typemaps to be applied to std::string& arguments
%typemap(jstype) std::string& OUTPUT "String[]"
%typemap(jtype) std::string& OUTPUT "String[]"
%typemap(jni) std::string& OUTPUT "jobjectArray"
%typemap(javain) std::string& OUTPUT "$javainput"
%typemap(in) std::string& OUTPUT (std::string temp) {
if (!$input) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return $null;
}
if (JCALL1(GetArrayLength, jenv, $input) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
}
$1 = &temp;
}
%typemap(argout) std::string& OUTPUT {
jstring jvalue = JCALL1(NewStringUTF, jenv, temp$argnum.c_str());
JCALL3(SetObjectArrayElement, jenv, $input, 0, jvalue);
}
#endif
%include "common.hpp"