So I'm trying to make some elementary Java bindings on OSX for OpenCV (
http://opencv.willowgarage.com/wiki/). Having never used SWIG before, I'm just trying to access some of the global functions in core. Here are the relevant sections from the header files:
==== opencv2/core/core.hpp ====
...
#include "opencv2/core/types_c.h"
...
namespace cv {
...
CV_EXPORTS_W int64 getTickCount();
...
}
===========================
==== opencv2/core/types_c.h ====
...
#if !defined _MSC_VER && !defined __BORLANDC__
#include <stdint.h>
#endif
...
#define CV_EXPORTS_W CV_EXPORTS
...
#if (defined WIN32 || defined _WIN32 || defined WINCE) && defined CVAPI_EXPORTS
#define CV_EXPORTS __declspec(dllexport)
#else
#define CV_EXPORTS
#endif
...
#if defined _MSC_VER || defined __BORLANDC__
typedef __int64 int64;
typedef unsigned __int64 uint64;
#define CV_BIG_INT(n) n##I64
#define CV_BIG_UINT(n) n##UI64
#else
typedef int64_t int64;
typedef uint64_t uint64;
#define CV_BIG_INT(n) n##LL
#define CV_BIG_UINT(n) n##ULL
#endif
============================
So, because I'm not on Windows, CV_EXPORTS_W should be nothing, and int64 should be int64_t, which is defined in stdint.h.
Here's my interface file:
==== opencv.i ====
%module OpencvCoreGlobal
%{
#include "opencv2/core/core.hpp"
%}
namespace cv {
extern int64 getTickCount();
}
================
The problem that I'm having is that SWIG appears to treat int64 as an opaque type rather than a Java long. What am I doing wrong?
===== Command line =====
$ swig -verbose -I/usr/local/include -java -c++ opencv.i
LangSubDir: java
Search paths:
./
/usr/local/include/
./swig_lib/java/
/usr/share/swig/1.3.31/java/
./swig_lib/
/usr/share/swig/1.3.31/
Preprocessing...
Starting language-specific parse...
Processing types...
C++ analysis...
Generating wrappers...
$
================
======= OpencvCoreGlobal.java =======
public class OpencvCoreGlobal {
public static SWIGTYPE_p_int64 getTickCount() {
return new SWIGTYPE_p_int64(OpencvCoreGlobalJNI.getTickCount(), true);
}
}
==================================
====== OpencvCoreGlobalJNI.java ======
class OpencvCoreGlobalJNI {
public final static native long getTickCount();
}
==================================
====== SWIGTYPE_p_int64.java ========
public class SWIGTYPE_p_int64 {
private long swigCPtr;
protected SWIGTYPE_p_int64(long cPtr, boolean futureUse) {
swigCPtr = cPtr;
}
protected SWIGTYPE_p_int64() {
swigCPtr = 0;
}
protected static long getCPtr(SWIGTYPE_p_int64 obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}
=================================
Thanks,
--Rob