I am trying to wrap a native C++ library using swig, and I am stuck at trying to convert time_t
in C, to long
in Java. I have successfully used swig with python, but so far I am unable to get the above typemap to work in Java.
In python it looks like this
%typemap(in) time_t
{
if (PyLong_Check($input))
$1 = (time_t) PyLong_AsLong($input);
else if (PyInt_Check($input))
$1 = (time_t) PyInt_AsLong($input);
else if (PyFloat_Check($input))
$1 = (time_t) PyFloat_AsDouble($input);
else {
PyErr_SetString(PyExc_TypeError,"Expected a large number");
return NULL;
}
}
%typemap(out) time_t
{
$result = PyLong_FromLong((long)$1);
}
I guess the in map from Java to C would be:
%typemap(in) time_t {
$1 = (time_t) $input;
}
How would I complete the out map from C to Java?
%typemap(out) time_t ???
Would I need typemaps like the ones below?
%typemap(jni)
%typemap(jtype)
%typemap(jstype)
I need this in order to wrap C functions like this:
time_t manipulate_time (time_t dt);