Commit ca8a1d2c authored by Ahmed Ashour's avatar Ahmed Ashour

java: generated code inline return

parent 1810702b
...@@ -33,8 +33,7 @@ public class KeyPoint { ...@@ -33,8 +33,7 @@ public class KeyPoint {
public int class_id; public int class_id;
// javadoc:KeyPoint::KeyPoint(x,y,_size,_angle,_response,_octave,_class_id) // javadoc:KeyPoint::KeyPoint(x,y,_size,_angle,_response,_octave,_class_id)
public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id) public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id) {
{
pt = new Point(x, y); pt = new Point(x, y);
size = _size; size = _size;
angle = _angle; angle = _angle;
...@@ -44,32 +43,27 @@ public class KeyPoint { ...@@ -44,32 +43,27 @@ public class KeyPoint {
} }
// javadoc: KeyPoint::KeyPoint() // javadoc: KeyPoint::KeyPoint()
public KeyPoint() public KeyPoint() {
{
this(0, 0, 0, -1, 0, 0, -1); this(0, 0, 0, -1, 0, 0, -1);
} }
// javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave) // javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave)
public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave) public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave) {
{
this(x, y, _size, _angle, _response, _octave, -1); this(x, y, _size, _angle, _response, _octave, -1);
} }
// javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response) // javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response)
public KeyPoint(float x, float y, float _size, float _angle, float _response) public KeyPoint(float x, float y, float _size, float _angle, float _response) {
{
this(x, y, _size, _angle, _response, 0, -1); this(x, y, _size, _angle, _response, 0, -1);
} }
// javadoc: KeyPoint::KeyPoint(x, y, _size, _angle) // javadoc: KeyPoint::KeyPoint(x, y, _size, _angle)
public KeyPoint(float x, float y, float _size, float _angle) public KeyPoint(float x, float y, float _size, float _angle) {
{
this(x, y, _size, _angle, 0, 0, -1); this(x, y, _size, _angle, 0, 0, -1);
} }
// javadoc: KeyPoint::KeyPoint(x, y, _size) // javadoc: KeyPoint::KeyPoint(x, y, _size)
public KeyPoint(float x, float y, float _size) public KeyPoint(float x, float y, float _size) {
{
this(x, y, _size, -1, 0, 0, -1); this(x, y, _size, -1, 0, 0, -1);
} }
......
...@@ -8,8 +8,7 @@ public class Mat { ...@@ -8,8 +8,7 @@ public class Mat {
public final long nativeObj; public final long nativeObj;
public Mat(long addr) public Mat(long addr) {
{
if (addr == 0) if (addr == 0)
throw new UnsupportedOperationException("Native object address is NULL"); throw new UnsupportedOperationException("Native object address is NULL");
nativeObj = addr; nativeObj = addr;
...@@ -20,12 +19,8 @@ public class Mat { ...@@ -20,12 +19,8 @@ public class Mat {
// //
// javadoc: Mat::Mat() // javadoc: Mat::Mat()
public Mat() public Mat() {
{
nativeObj = n_Mat(); nativeObj = n_Mat();
return;
} }
// //
...@@ -33,12 +28,8 @@ public class Mat { ...@@ -33,12 +28,8 @@ public class Mat {
// //
// javadoc: Mat::Mat(rows, cols, type) // javadoc: Mat::Mat(rows, cols, type)
public Mat(int rows, int cols, int type) public Mat(int rows, int cols, int type) {
{
nativeObj = n_Mat(rows, cols, type); nativeObj = n_Mat(rows, cols, type);
return;
} }
// //
...@@ -46,12 +37,8 @@ public class Mat { ...@@ -46,12 +37,8 @@ public class Mat {
// //
// javadoc: Mat::Mat(rows, cols, type, data) // javadoc: Mat::Mat(rows, cols, type, data)
public Mat(int rows, int cols, int type, ByteBuffer data) public Mat(int rows, int cols, int type, ByteBuffer data) {
{
nativeObj = n_Mat(rows, cols, type, data); nativeObj = n_Mat(rows, cols, type, data);
return;
} }
// //
...@@ -59,12 +46,8 @@ public class Mat { ...@@ -59,12 +46,8 @@ public class Mat {
// //
// javadoc: Mat::Mat(size, type) // javadoc: Mat::Mat(size, type)
public Mat(Size size, int type) public Mat(Size size, int type) {
{
nativeObj = n_Mat(size.width, size.height, type); nativeObj = n_Mat(size.width, size.height, type);
return;
} }
// //
...@@ -72,12 +55,8 @@ public class Mat { ...@@ -72,12 +55,8 @@ public class Mat {
// //
// javadoc: Mat::Mat(sizes, type) // javadoc: Mat::Mat(sizes, type)
public Mat(int[] sizes, int type) public Mat(int[] sizes, int type) {
{
nativeObj = n_Mat(sizes.length, sizes, type); nativeObj = n_Mat(sizes.length, sizes, type);
return;
} }
// //
...@@ -85,12 +64,8 @@ public class Mat { ...@@ -85,12 +64,8 @@ public class Mat {
// //
// javadoc: Mat::Mat(rows, cols, type, s) // javadoc: Mat::Mat(rows, cols, type, s)
public Mat(int rows, int cols, int type, Scalar s) public Mat(int rows, int cols, int type, Scalar s) {
{
nativeObj = n_Mat(rows, cols, type, s.val[0], s.val[1], s.val[2], s.val[3]); nativeObj = n_Mat(rows, cols, type, s.val[0], s.val[1], s.val[2], s.val[3]);
return;
} }
// //
...@@ -98,12 +73,8 @@ public class Mat { ...@@ -98,12 +73,8 @@ public class Mat {
// //
// javadoc: Mat::Mat(size, type, s) // javadoc: Mat::Mat(size, type, s)
public Mat(Size size, int type, Scalar s) public Mat(Size size, int type, Scalar s) {
{
nativeObj = n_Mat(size.width, size.height, type, s.val[0], s.val[1], s.val[2], s.val[3]); nativeObj = n_Mat(size.width, size.height, type, s.val[0], s.val[1], s.val[2], s.val[3]);
return;
} }
// //
...@@ -111,12 +82,8 @@ public class Mat { ...@@ -111,12 +82,8 @@ public class Mat {
// //
// javadoc: Mat::Mat(sizes, type, s) // javadoc: Mat::Mat(sizes, type, s)
public Mat(int[] sizes, int type, Scalar s) public Mat(int[] sizes, int type, Scalar s) {
{
nativeObj = n_Mat(sizes.length, sizes, type, s.val[0], s.val[1], s.val[2], s.val[3]); nativeObj = n_Mat(sizes.length, sizes, type, s.val[0], s.val[1], s.val[2], s.val[3]);
return;
} }
// //
...@@ -124,21 +91,13 @@ public class Mat { ...@@ -124,21 +91,13 @@ public class Mat {
// //
// javadoc: Mat::Mat(m, rowRange, colRange) // javadoc: Mat::Mat(m, rowRange, colRange)
public Mat(Mat m, Range rowRange, Range colRange) public Mat(Mat m, Range rowRange, Range colRange) {
{
nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end); nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end);
return;
} }
// javadoc: Mat::Mat(m, rowRange) // javadoc: Mat::Mat(m, rowRange)
public Mat(Mat m, Range rowRange) public Mat(Mat m, Range rowRange) {
{
nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end); nativeObj = n_Mat(m.nativeObj, rowRange.start, rowRange.end);
return;
} }
// //
...@@ -146,12 +105,8 @@ public class Mat { ...@@ -146,12 +105,8 @@ public class Mat {
// //
// javadoc: Mat::Mat(m, ranges) // javadoc: Mat::Mat(m, ranges)
public Mat(Mat m, Range[] ranges) public Mat(Mat m, Range[] ranges) {
{
nativeObj = n_Mat(m.nativeObj, ranges); nativeObj = n_Mat(m.nativeObj, ranges);
return;
} }
// //
...@@ -159,12 +114,8 @@ public class Mat { ...@@ -159,12 +114,8 @@ public class Mat {
// //
// javadoc: Mat::Mat(m, roi) // javadoc: Mat::Mat(m, roi)
public Mat(Mat m, Rect roi) public Mat(Mat m, Rect roi) {
{
nativeObj = n_Mat(m.nativeObj, roi.y, roi.y + roi.height, roi.x, roi.x + roi.width); nativeObj = n_Mat(m.nativeObj, roi.y, roi.y + roi.height, roi.x, roi.x + roi.width);
return;
} }
// //
...@@ -172,12 +123,8 @@ public class Mat { ...@@ -172,12 +123,8 @@ public class Mat {
// //
// javadoc: Mat::adjustROI(dtop, dbottom, dleft, dright) // javadoc: Mat::adjustROI(dtop, dbottom, dleft, dright)
public Mat adjustROI(int dtop, int dbottom, int dleft, int dright) public Mat adjustROI(int dtop, int dbottom, int dleft, int dright) {
{ return new Mat(n_adjustROI(nativeObj, dtop, dbottom, dleft, dright));
Mat retVal = new Mat(n_adjustROI(nativeObj, dtop, dbottom, dleft, dright));
return retVal;
} }
// //
...@@ -185,21 +132,13 @@ public class Mat { ...@@ -185,21 +132,13 @@ public class Mat {
// //
// javadoc: Mat::assignTo(m, type) // javadoc: Mat::assignTo(m, type)
public void assignTo(Mat m, int type) public void assignTo(Mat m, int type) {
{
n_assignTo(nativeObj, m.nativeObj, type); n_assignTo(nativeObj, m.nativeObj, type);
return;
} }
// javadoc: Mat::assignTo(m) // javadoc: Mat::assignTo(m)
public void assignTo(Mat m) public void assignTo(Mat m) {
{
n_assignTo(nativeObj, m.nativeObj); n_assignTo(nativeObj, m.nativeObj);
return;
} }
// //
...@@ -207,12 +146,8 @@ public class Mat { ...@@ -207,12 +146,8 @@ public class Mat {
// //
// javadoc: Mat::channels() // javadoc: Mat::channels()
public int channels() public int channels() {
{ return n_channels(nativeObj);
int retVal = n_channels(nativeObj);
return retVal;
} }
// //
...@@ -221,30 +156,18 @@ public class Mat { ...@@ -221,30 +156,18 @@ public class Mat {
// //
// javadoc: Mat::checkVector(elemChannels, depth, requireContinuous) // javadoc: Mat::checkVector(elemChannels, depth, requireContinuous)
public int checkVector(int elemChannels, int depth, boolean requireContinuous) public int checkVector(int elemChannels, int depth, boolean requireContinuous) {
{ return n_checkVector(nativeObj, elemChannels, depth, requireContinuous);
int retVal = n_checkVector(nativeObj, elemChannels, depth, requireContinuous);
return retVal;
} }
// javadoc: Mat::checkVector(elemChannels, depth) // javadoc: Mat::checkVector(elemChannels, depth)
public int checkVector(int elemChannels, int depth) public int checkVector(int elemChannels, int depth) {
{ return n_checkVector(nativeObj, elemChannels, depth);
int retVal = n_checkVector(nativeObj, elemChannels, depth);
return retVal;
} }
// javadoc: Mat::checkVector(elemChannels) // javadoc: Mat::checkVector(elemChannels)
public int checkVector(int elemChannels) public int checkVector(int elemChannels) {
{ return n_checkVector(nativeObj, elemChannels);
int retVal = n_checkVector(nativeObj, elemChannels);
return retVal;
} }
// //
...@@ -252,12 +175,8 @@ public class Mat { ...@@ -252,12 +175,8 @@ public class Mat {
// //
// javadoc: Mat::clone() // javadoc: Mat::clone()
public Mat clone() public Mat clone() {
{ return new Mat(n_clone(nativeObj));
Mat retVal = new Mat(n_clone(nativeObj));
return retVal;
} }
// //
...@@ -265,12 +184,8 @@ public class Mat { ...@@ -265,12 +184,8 @@ public class Mat {
// //
// javadoc: Mat::col(x) // javadoc: Mat::col(x)
public Mat col(int x) public Mat col(int x) {
{ return new Mat(n_col(nativeObj, x));
Mat retVal = new Mat(n_col(nativeObj, x));
return retVal;
} }
// //
...@@ -278,12 +193,8 @@ public class Mat { ...@@ -278,12 +193,8 @@ public class Mat {
// //
// javadoc: Mat::colRange(startcol, endcol) // javadoc: Mat::colRange(startcol, endcol)
public Mat colRange(int startcol, int endcol) public Mat colRange(int startcol, int endcol) {
{ return new Mat(n_colRange(nativeObj, startcol, endcol));
Mat retVal = new Mat(n_colRange(nativeObj, startcol, endcol));
return retVal;
} }
// //
...@@ -291,12 +202,8 @@ public class Mat { ...@@ -291,12 +202,8 @@ public class Mat {
// //
// javadoc: Mat::colRange(r) // javadoc: Mat::colRange(r)
public Mat colRange(Range r) public Mat colRange(Range r) {
{ return new Mat(n_colRange(nativeObj, r.start, r.end));
Mat retVal = new Mat(n_colRange(nativeObj, r.start, r.end));
return retVal;
} }
// //
...@@ -304,12 +211,8 @@ public class Mat { ...@@ -304,12 +211,8 @@ public class Mat {
// //
// javadoc: Mat::dims() // javadoc: Mat::dims()
public int dims() public int dims() {
{ return n_dims(nativeObj);
int retVal = n_dims(nativeObj);
return retVal;
} }
// //
...@@ -317,12 +220,8 @@ public class Mat { ...@@ -317,12 +220,8 @@ public class Mat {
// //
// javadoc: Mat::cols() // javadoc: Mat::cols()
public int cols() public int cols() {
{ return n_cols(nativeObj);
int retVal = n_cols(nativeObj);
return retVal;
} }
// //
...@@ -331,30 +230,18 @@ public class Mat { ...@@ -331,30 +230,18 @@ public class Mat {
// //
// javadoc: Mat::convertTo(m, rtype, alpha, beta) // javadoc: Mat::convertTo(m, rtype, alpha, beta)
public void convertTo(Mat m, int rtype, double alpha, double beta) public void convertTo(Mat m, int rtype, double alpha, double beta) {
{
n_convertTo(nativeObj, m.nativeObj, rtype, alpha, beta); n_convertTo(nativeObj, m.nativeObj, rtype, alpha, beta);
return;
} }
// javadoc: Mat::convertTo(m, rtype, alpha) // javadoc: Mat::convertTo(m, rtype, alpha)
public void convertTo(Mat m, int rtype, double alpha) public void convertTo(Mat m, int rtype, double alpha) {
{
n_convertTo(nativeObj, m.nativeObj, rtype, alpha); n_convertTo(nativeObj, m.nativeObj, rtype, alpha);
return;
} }
// javadoc: Mat::convertTo(m, rtype) // javadoc: Mat::convertTo(m, rtype)
public void convertTo(Mat m, int rtype) public void convertTo(Mat m, int rtype) {
{
n_convertTo(nativeObj, m.nativeObj, rtype); n_convertTo(nativeObj, m.nativeObj, rtype);
return;
} }
// //
...@@ -362,12 +249,8 @@ public class Mat { ...@@ -362,12 +249,8 @@ public class Mat {
// //
// javadoc: Mat::copyTo(m) // javadoc: Mat::copyTo(m)
public void copyTo(Mat m) public void copyTo(Mat m) {
{
n_copyTo(nativeObj, m.nativeObj); n_copyTo(nativeObj, m.nativeObj);
return;
} }
// //
...@@ -375,12 +258,8 @@ public class Mat { ...@@ -375,12 +258,8 @@ public class Mat {
// //
// javadoc: Mat::copyTo(m, mask) // javadoc: Mat::copyTo(m, mask)
public void copyTo(Mat m, Mat mask) public void copyTo(Mat m, Mat mask) {
{
n_copyTo(nativeObj, m.nativeObj, mask.nativeObj); n_copyTo(nativeObj, m.nativeObj, mask.nativeObj);
return;
} }
// //
...@@ -388,12 +267,8 @@ public class Mat { ...@@ -388,12 +267,8 @@ public class Mat {
// //
// javadoc: Mat::create(rows, cols, type) // javadoc: Mat::create(rows, cols, type)
public void create(int rows, int cols, int type) public void create(int rows, int cols, int type) {
{
n_create(nativeObj, rows, cols, type); n_create(nativeObj, rows, cols, type);
return;
} }
// //
...@@ -401,12 +276,8 @@ public class Mat { ...@@ -401,12 +276,8 @@ public class Mat {
// //
// javadoc: Mat::create(size, type) // javadoc: Mat::create(size, type)
public void create(Size size, int type) public void create(Size size, int type) {
{
n_create(nativeObj, size.width, size.height, type); n_create(nativeObj, size.width, size.height, type);
return;
} }
// //
...@@ -414,12 +285,8 @@ public class Mat { ...@@ -414,12 +285,8 @@ public class Mat {
// //
// javadoc: Mat::create(sizes, type) // javadoc: Mat::create(sizes, type)
public void create(int[] sizes, int type) public void create(int[] sizes, int type) {
{
n_create(nativeObj, sizes.length, sizes, type); n_create(nativeObj, sizes.length, sizes, type);
return;
} }
// //
...@@ -427,11 +294,8 @@ public class Mat { ...@@ -427,11 +294,8 @@ public class Mat {
// //
// javadoc: Mat::copySize(m) // javadoc: Mat::copySize(m)
public void copySize(Mat m) public void copySize(Mat m) {
{
n_copySize(nativeObj, m.nativeObj); n_copySize(nativeObj, m.nativeObj);
return;
} }
// //
...@@ -439,12 +303,8 @@ public class Mat { ...@@ -439,12 +303,8 @@ public class Mat {
// //
// javadoc: Mat::cross(m) // javadoc: Mat::cross(m)
public Mat cross(Mat m) public Mat cross(Mat m) {
{ return new Mat(n_cross(nativeObj, m.nativeObj));
Mat retVal = new Mat(n_cross(nativeObj, m.nativeObj));
return retVal;
} }
// //
...@@ -452,12 +312,8 @@ public class Mat { ...@@ -452,12 +312,8 @@ public class Mat {
// //
// javadoc: Mat::dataAddr() // javadoc: Mat::dataAddr()
public long dataAddr() public long dataAddr() {
{ return n_dataAddr(nativeObj);
long retVal = n_dataAddr(nativeObj);
return retVal;
} }
// //
...@@ -465,12 +321,8 @@ public class Mat { ...@@ -465,12 +321,8 @@ public class Mat {
// //
// javadoc: Mat::depth() // javadoc: Mat::depth()
public int depth() public int depth() {
{ return n_depth(nativeObj);
int retVal = n_depth(nativeObj);
return retVal;
} }
// //
...@@ -478,21 +330,13 @@ public class Mat { ...@@ -478,21 +330,13 @@ public class Mat {
// //
// javadoc: Mat::diag(d) // javadoc: Mat::diag(d)
public Mat diag(int d) public Mat diag(int d) {
{ return new Mat(n_diag(nativeObj, d));
Mat retVal = new Mat(n_diag(nativeObj, d));
return retVal;
} }
// javadoc: Mat::diag() // javadoc: Mat::diag()
public Mat diag() public Mat diag() {
{ return new Mat(n_diag(nativeObj, 0));
Mat retVal = new Mat(n_diag(nativeObj, 0));
return retVal;
} }
// //
...@@ -500,12 +344,8 @@ public class Mat { ...@@ -500,12 +344,8 @@ public class Mat {
// //
// javadoc: Mat::diag(d) // javadoc: Mat::diag(d)
public static Mat diag(Mat d) public static Mat diag(Mat d) {
{ return new Mat(n_diag(d.nativeObj));
Mat retVal = new Mat(n_diag(d.nativeObj));
return retVal;
} }
// //
...@@ -513,12 +353,8 @@ public class Mat { ...@@ -513,12 +353,8 @@ public class Mat {
// //
// javadoc: Mat::dot(m) // javadoc: Mat::dot(m)
public double dot(Mat m) public double dot(Mat m) {
{ return n_dot(nativeObj, m.nativeObj);
double retVal = n_dot(nativeObj, m.nativeObj);
return retVal;
} }
// //
...@@ -526,12 +362,8 @@ public class Mat { ...@@ -526,12 +362,8 @@ public class Mat {
// //
// javadoc: Mat::elemSize() // javadoc: Mat::elemSize()
public long elemSize() public long elemSize() {
{ return n_elemSize(nativeObj);
long retVal = n_elemSize(nativeObj);
return retVal;
} }
// //
...@@ -539,12 +371,8 @@ public class Mat { ...@@ -539,12 +371,8 @@ public class Mat {
// //
// javadoc: Mat::elemSize1() // javadoc: Mat::elemSize1()
public long elemSize1() public long elemSize1() {
{ return n_elemSize1(nativeObj);
long retVal = n_elemSize1(nativeObj);
return retVal;
} }
// //
...@@ -552,12 +380,8 @@ public class Mat { ...@@ -552,12 +380,8 @@ public class Mat {
// //
// javadoc: Mat::empty() // javadoc: Mat::empty()
public boolean empty() public boolean empty() {
{ return n_empty(nativeObj);
boolean retVal = n_empty(nativeObj);
return retVal;
} }
// //
...@@ -565,12 +389,8 @@ public class Mat { ...@@ -565,12 +389,8 @@ public class Mat {
// //
// javadoc: Mat::eye(rows, cols, type) // javadoc: Mat::eye(rows, cols, type)
public static Mat eye(int rows, int cols, int type) public static Mat eye(int rows, int cols, int type) {
{ return new Mat(n_eye(rows, cols, type));
Mat retVal = new Mat(n_eye(rows, cols, type));
return retVal;
} }
// //
...@@ -578,12 +398,8 @@ public class Mat { ...@@ -578,12 +398,8 @@ public class Mat {
// //
// javadoc: Mat::eye(size, type) // javadoc: Mat::eye(size, type)
public static Mat eye(Size size, int type) public static Mat eye(Size size, int type) {
{ return new Mat(n_eye(size.width, size.height, type));
Mat retVal = new Mat(n_eye(size.width, size.height, type));
return retVal;
} }
// //
...@@ -591,21 +407,13 @@ public class Mat { ...@@ -591,21 +407,13 @@ public class Mat {
// //
// javadoc: Mat::inv(method) // javadoc: Mat::inv(method)
public Mat inv(int method) public Mat inv(int method) {
{ return new Mat(n_inv(nativeObj, method));
Mat retVal = new Mat(n_inv(nativeObj, method));
return retVal;
} }
// javadoc: Mat::inv() // javadoc: Mat::inv()
public Mat inv() public Mat inv() {
{ return new Mat(n_inv(nativeObj));
Mat retVal = new Mat(n_inv(nativeObj));
return retVal;
} }
// //
...@@ -613,12 +421,8 @@ public class Mat { ...@@ -613,12 +421,8 @@ public class Mat {
// //
// javadoc: Mat::isContinuous() // javadoc: Mat::isContinuous()
public boolean isContinuous() public boolean isContinuous() {
{ return n_isContinuous(nativeObj);
boolean retVal = n_isContinuous(nativeObj);
return retVal;
} }
// //
...@@ -626,12 +430,8 @@ public class Mat { ...@@ -626,12 +430,8 @@ public class Mat {
// //
// javadoc: Mat::isSubmatrix() // javadoc: Mat::isSubmatrix()
public boolean isSubmatrix() public boolean isSubmatrix() {
{ return n_isSubmatrix(nativeObj);
boolean retVal = n_isSubmatrix(nativeObj);
return retVal;
} }
// //
...@@ -639,14 +439,18 @@ public class Mat { ...@@ -639,14 +439,18 @@ public class Mat {
// //
// javadoc: Mat::locateROI(wholeSize, ofs) // javadoc: Mat::locateROI(wholeSize, ofs)
public void locateROI(Size wholeSize, Point ofs) public void locateROI(Size wholeSize, Point ofs) {
{
double[] wholeSize_out = new double[2]; double[] wholeSize_out = new double[2];
double[] ofs_out = new double[2]; double[] ofs_out = new double[2];
locateROI_0(nativeObj, wholeSize_out, ofs_out); locateROI_0(nativeObj, wholeSize_out, ofs_out);
if(wholeSize!=null){ wholeSize.width = wholeSize_out[0]; wholeSize.height = wholeSize_out[1]; } if (wholeSize != null) {
if(ofs!=null){ ofs.x = ofs_out[0]; ofs.y = ofs_out[1]; } wholeSize.width = wholeSize_out[0];
return; wholeSize.height = wholeSize_out[1];
}
if (ofs != null) {
ofs.x = ofs_out[0];
ofs.y = ofs_out[1];
}
} }
// //
...@@ -654,21 +458,13 @@ public class Mat { ...@@ -654,21 +458,13 @@ public class Mat {
// //
// javadoc: Mat::mul(m, scale) // javadoc: Mat::mul(m, scale)
public Mat mul(Mat m, double scale) public Mat mul(Mat m, double scale) {
{ return new Mat(n_mul(nativeObj, m.nativeObj, scale));
Mat retVal = new Mat(n_mul(nativeObj, m.nativeObj, scale));
return retVal;
} }
// javadoc: Mat::mul(m) // javadoc: Mat::mul(m)
public Mat mul(Mat m) public Mat mul(Mat m) {
{ return new Mat(n_mul(nativeObj, m.nativeObj));
Mat retVal = new Mat(n_mul(nativeObj, m.nativeObj));
return retVal;
} }
// //
...@@ -676,12 +472,8 @@ public class Mat { ...@@ -676,12 +472,8 @@ public class Mat {
// //
// javadoc: Mat::ones(rows, cols, type) // javadoc: Mat::ones(rows, cols, type)
public static Mat ones(int rows, int cols, int type) public static Mat ones(int rows, int cols, int type) {
{ return new Mat(n_ones(rows, cols, type));
Mat retVal = new Mat(n_ones(rows, cols, type));
return retVal;
} }
// //
...@@ -689,12 +481,8 @@ public class Mat { ...@@ -689,12 +481,8 @@ public class Mat {
// //
// javadoc: Mat::ones(size, type) // javadoc: Mat::ones(size, type)
public static Mat ones(Size size, int type) public static Mat ones(Size size, int type) {
{ return new Mat(n_ones(size.width, size.height, type));
Mat retVal = new Mat(n_ones(size.width, size.height, type));
return retVal;
} }
// //
...@@ -702,12 +490,8 @@ public class Mat { ...@@ -702,12 +490,8 @@ public class Mat {
// //
// javadoc: Mat::ones(sizes, type) // javadoc: Mat::ones(sizes, type)
public static Mat ones(int[] sizes, int type) public static Mat ones(int[] sizes, int type) {
{ return new Mat(n_ones(sizes.length, sizes, type));
Mat retVal = new Mat(n_ones(sizes.length, sizes, type));
return retVal;
} }
// //
...@@ -715,12 +499,8 @@ public class Mat { ...@@ -715,12 +499,8 @@ public class Mat {
// //
// javadoc: Mat::push_back(m) // javadoc: Mat::push_back(m)
public void push_back(Mat m) public void push_back(Mat m) {
{
n_push_back(nativeObj, m.nativeObj); n_push_back(nativeObj, m.nativeObj);
return;
} }
// //
...@@ -728,12 +508,8 @@ public class Mat { ...@@ -728,12 +508,8 @@ public class Mat {
// //
// javadoc: Mat::release() // javadoc: Mat::release()
public void release() public void release() {
{
n_release(nativeObj); n_release(nativeObj);
return;
} }
// //
...@@ -741,21 +517,13 @@ public class Mat { ...@@ -741,21 +517,13 @@ public class Mat {
// //
// javadoc: Mat::reshape(cn, rows) // javadoc: Mat::reshape(cn, rows)
public Mat reshape(int cn, int rows) public Mat reshape(int cn, int rows) {
{ return new Mat(n_reshape(nativeObj, cn, rows));
Mat retVal = new Mat(n_reshape(nativeObj, cn, rows));
return retVal;
} }
// javadoc: Mat::reshape(cn) // javadoc: Mat::reshape(cn)
public Mat reshape(int cn) public Mat reshape(int cn) {
{ return new Mat(n_reshape(nativeObj, cn));
Mat retVal = new Mat(n_reshape(nativeObj, cn));
return retVal;
} }
// //
...@@ -763,11 +531,8 @@ public class Mat { ...@@ -763,11 +531,8 @@ public class Mat {
// //
// javadoc: Mat::reshape(cn, newshape) // javadoc: Mat::reshape(cn, newshape)
public Mat reshape(int cn, int[] newshape) public Mat reshape(int cn, int[] newshape) {
{ return new Mat(n_reshape_1(nativeObj, cn, newshape.length, newshape));
Mat retVal = new Mat(n_reshape_1(nativeObj, cn, newshape.length, newshape));
return retVal;
} }
// //
...@@ -775,12 +540,8 @@ public class Mat { ...@@ -775,12 +540,8 @@ public class Mat {
// //
// javadoc: Mat::row(y) // javadoc: Mat::row(y)
public Mat row(int y) public Mat row(int y) {
{ return new Mat(n_row(nativeObj, y));
Mat retVal = new Mat(n_row(nativeObj, y));
return retVal;
} }
// //
...@@ -788,12 +549,8 @@ public class Mat { ...@@ -788,12 +549,8 @@ public class Mat {
// //
// javadoc: Mat::rowRange(startrow, endrow) // javadoc: Mat::rowRange(startrow, endrow)
public Mat rowRange(int startrow, int endrow) public Mat rowRange(int startrow, int endrow) {
{ return new Mat(n_rowRange(nativeObj, startrow, endrow));
Mat retVal = new Mat(n_rowRange(nativeObj, startrow, endrow));
return retVal;
} }
// //
...@@ -801,12 +558,8 @@ public class Mat { ...@@ -801,12 +558,8 @@ public class Mat {
// //
// javadoc: Mat::rowRange(r) // javadoc: Mat::rowRange(r)
public Mat rowRange(Range r) public Mat rowRange(Range r) {
{ return new Mat(n_rowRange(nativeObj, r.start, r.end));
Mat retVal = new Mat(n_rowRange(nativeObj, r.start, r.end));
return retVal;
} }
// //
...@@ -814,12 +567,8 @@ public class Mat { ...@@ -814,12 +567,8 @@ public class Mat {
// //
// javadoc: Mat::rows() // javadoc: Mat::rows()
public int rows() public int rows() {
{ return n_rows(nativeObj);
int retVal = n_rows(nativeObj);
return retVal;
} }
// //
...@@ -827,12 +576,8 @@ public class Mat { ...@@ -827,12 +576,8 @@ public class Mat {
// //
// javadoc: Mat::operator =(s) // javadoc: Mat::operator =(s)
public Mat setTo(Scalar s) public Mat setTo(Scalar s) {
{ return new Mat(n_setTo(nativeObj, s.val[0], s.val[1], s.val[2], s.val[3]));
Mat retVal = new Mat(n_setTo(nativeObj, s.val[0], s.val[1], s.val[2], s.val[3]));
return retVal;
} }
// //
...@@ -840,12 +585,8 @@ public class Mat { ...@@ -840,12 +585,8 @@ public class Mat {
// //
// javadoc: Mat::setTo(value, mask) // javadoc: Mat::setTo(value, mask)
public Mat setTo(Scalar value, Mat mask) public Mat setTo(Scalar value, Mat mask) {
{ return new Mat(n_setTo(nativeObj, value.val[0], value.val[1], value.val[2], value.val[3], mask.nativeObj));
Mat retVal = new Mat(n_setTo(nativeObj, value.val[0], value.val[1], value.val[2], value.val[3], mask.nativeObj));
return retVal;
} }
// //
...@@ -853,21 +594,13 @@ public class Mat { ...@@ -853,21 +594,13 @@ public class Mat {
// //
// javadoc: Mat::setTo(value, mask) // javadoc: Mat::setTo(value, mask)
public Mat setTo(Mat value, Mat mask) public Mat setTo(Mat value, Mat mask) {
{ return new Mat(n_setTo(nativeObj, value.nativeObj, mask.nativeObj));
Mat retVal = new Mat(n_setTo(nativeObj, value.nativeObj, mask.nativeObj));
return retVal;
} }
// javadoc: Mat::setTo(value) // javadoc: Mat::setTo(value)
public Mat setTo(Mat value) public Mat setTo(Mat value) {
{ return new Mat(n_setTo(nativeObj, value.nativeObj));
Mat retVal = new Mat(n_setTo(nativeObj, value.nativeObj));
return retVal;
} }
// //
...@@ -875,12 +608,8 @@ public class Mat { ...@@ -875,12 +608,8 @@ public class Mat {
// //
// javadoc: Mat::size() // javadoc: Mat::size()
public Size size() public Size size() {
{ return new Size(n_size(nativeObj));
Size retVal = new Size(n_size(nativeObj));
return retVal;
} }
// //
...@@ -888,11 +617,8 @@ public class Mat { ...@@ -888,11 +617,8 @@ public class Mat {
// //
// javadoc: Mat::size(int i) // javadoc: Mat::size(int i)
public int size(int i) public int size(int i) {
{ return n_size_i(nativeObj, i);
int retVal = n_size_i(nativeObj, i);
return retVal;
} }
// //
...@@ -900,21 +626,13 @@ public class Mat { ...@@ -900,21 +626,13 @@ public class Mat {
// //
// javadoc: Mat::step1(i) // javadoc: Mat::step1(i)
public long step1(int i) public long step1(int i) {
{ return n_step1(nativeObj, i);
long retVal = n_step1(nativeObj, i);
return retVal;
} }
// javadoc: Mat::step1() // javadoc: Mat::step1()
public long step1() public long step1() {
{ return n_step1(nativeObj);
long retVal = n_step1(nativeObj);
return retVal;
} }
// //
...@@ -923,12 +641,8 @@ public class Mat { ...@@ -923,12 +641,8 @@ public class Mat {
// //
// javadoc: Mat::operator()(rowStart, rowEnd, colStart, colEnd) // javadoc: Mat::operator()(rowStart, rowEnd, colStart, colEnd)
public Mat submat(int rowStart, int rowEnd, int colStart, int colEnd) public Mat submat(int rowStart, int rowEnd, int colStart, int colEnd) {
{ return new Mat(n_submat_rr(nativeObj, rowStart, rowEnd, colStart, colEnd));
Mat retVal = new Mat(n_submat_rr(nativeObj, rowStart, rowEnd, colStart, colEnd));
return retVal;
} }
// //
...@@ -936,12 +650,8 @@ public class Mat { ...@@ -936,12 +650,8 @@ public class Mat {
// //
// javadoc: Mat::operator()(rowRange, colRange) // javadoc: Mat::operator()(rowRange, colRange)
public Mat submat(Range rowRange, Range colRange) public Mat submat(Range rowRange, Range colRange) {
{ return new Mat(n_submat_rr(nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end));
Mat retVal = new Mat(n_submat_rr(nativeObj, rowRange.start, rowRange.end, colRange.start, colRange.end));
return retVal;
} }
// //
...@@ -949,12 +659,8 @@ public class Mat { ...@@ -949,12 +659,8 @@ public class Mat {
// //
// javadoc: Mat::operator()(ranges[]) // javadoc: Mat::operator()(ranges[])
public Mat submat(Range[] ranges) public Mat submat(Range[] ranges) {
{ return new Mat(n_submat_ranges(nativeObj, ranges));
Mat retVal = new Mat(n_submat_ranges(nativeObj, ranges));
return retVal;
} }
// //
...@@ -962,12 +668,8 @@ public class Mat { ...@@ -962,12 +668,8 @@ public class Mat {
// //
// javadoc: Mat::operator()(roi) // javadoc: Mat::operator()(roi)
public Mat submat(Rect roi) public Mat submat(Rect roi) {
{ return new Mat(n_submat(nativeObj, roi.x, roi.y, roi.width, roi.height));
Mat retVal = new Mat(n_submat(nativeObj, roi.x, roi.y, roi.width, roi.height));
return retVal;
} }
// //
...@@ -975,12 +677,8 @@ public class Mat { ...@@ -975,12 +677,8 @@ public class Mat {
// //
// javadoc: Mat::t() // javadoc: Mat::t()
public Mat t() public Mat t() {
{ return new Mat(n_t(nativeObj));
Mat retVal = new Mat(n_t(nativeObj));
return retVal;
} }
// //
...@@ -988,12 +686,8 @@ public class Mat { ...@@ -988,12 +686,8 @@ public class Mat {
// //
// javadoc: Mat::total() // javadoc: Mat::total()
public long total() public long total() {
{ return n_total(nativeObj);
long retVal = n_total(nativeObj);
return retVal;
} }
// //
...@@ -1001,12 +695,8 @@ public class Mat { ...@@ -1001,12 +695,8 @@ public class Mat {
// //
// javadoc: Mat::type() // javadoc: Mat::type()
public int type() public int type() {
{ return n_type(nativeObj);
int retVal = n_type(nativeObj);
return retVal;
} }
// //
...@@ -1014,12 +704,8 @@ public class Mat { ...@@ -1014,12 +704,8 @@ public class Mat {
// //
// javadoc: Mat::zeros(rows, cols, type) // javadoc: Mat::zeros(rows, cols, type)
public static Mat zeros(int rows, int cols, int type) public static Mat zeros(int rows, int cols, int type) {
{ return new Mat(n_zeros(rows, cols, type));
Mat retVal = new Mat(n_zeros(rows, cols, type));
return retVal;
} }
// //
...@@ -1027,12 +713,8 @@ public class Mat { ...@@ -1027,12 +713,8 @@ public class Mat {
// //
// javadoc: Mat::zeros(size, type) // javadoc: Mat::zeros(size, type)
public static Mat zeros(Size size, int type) public static Mat zeros(Size size, int type) {
{ return new Mat(n_zeros(size.width, size.height, type));
Mat retVal = new Mat(n_zeros(size.width, size.height, type));
return retVal;
} }
// //
...@@ -1040,12 +722,8 @@ public class Mat { ...@@ -1040,12 +722,8 @@ public class Mat {
// //
// javadoc: Mat::zeros(sizes, type) // javadoc: Mat::zeros(sizes, type)
public static Mat zeros(int[] sizes, int type) public static Mat zeros(int[] sizes, int type) {
{ return new Mat(n_zeros(sizes.length, sizes, type));
Mat retVal = new Mat(n_zeros(sizes.length, sizes, type));
return retVal;
} }
@Override @Override
......
...@@ -222,7 +222,8 @@ class ClassInfo(GeneralInfo): ...@@ -222,7 +222,8 @@ class ClassInfo(GeneralInfo):
return Template("CLASS $namespace::$classpath.$name : $base").substitute(**self.__dict__) return Template("CLASS $namespace::$classpath.$name : $base").substitute(**self.__dict__)
def getAllImports(self, module): def getAllImports(self, module):
return ["import %s;" % c for c in sorted(self.imports) if not c.startswith('org.opencv.'+module)] return ["import %s;" % c for c in sorted(self.imports) if not c.startswith('org.opencv.'+module)
and (not c.startswith('java.lang.') or c.count('.') != 2)]
def addImports(self, ctype): def addImports(self, ctype):
if ctype in type_dict: if ctype in type_dict:
...@@ -285,8 +286,8 @@ class ClassInfo(GeneralInfo): ...@@ -285,8 +286,8 @@ class ClassInfo(GeneralInfo):
self.cpp_code.close() self.cpp_code.close()
def generateJavaCode(self, m, M): def generateJavaCode(self, m, M):
return Template(self.j_code.getvalue() + "\n\n" + \ return Template(self.j_code.getvalue() + "\n\n" +
self.jn_code.getvalue() + "\n}\n").substitute(\ self.jn_code.getvalue() + "\n}\n").substitute(
module = m, module = m,
name = self.name, name = self.name,
jname = self.jname, jname = self.jname,
...@@ -685,7 +686,7 @@ class JavaWrapperGenerator(object): ...@@ -685,7 +686,7 @@ class JavaWrapperGenerator(object):
jn_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) ) jn_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) )
jni_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) ) jni_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) )
j_prologue.append( "double[] %s_out = new double[%i];" % (a.name, len(fields)) ) j_prologue.append( "double[] %s_out = new double[%i];" % (a.name, len(fields)) )
c_epilogue.append( \ c_epilogue.append(
"jdouble tmp_%(n)s[%(cnt)i] = {%(args)s}; env->SetDoubleArrayRegion(%(n)s_out, 0, %(cnt)i, tmp_%(n)s);" % "jdouble tmp_%(n)s[%(cnt)i] = {%(args)s}; env->SetDoubleArrayRegion(%(n)s_out, 0, %(cnt)i, tmp_%(n)s);" %
{ "n" : a.name, "cnt" : len(fields), "args" : ", ".join(["(jdouble)" + a.name + f[1] for f in fields]) } ) { "n" : a.name, "cnt" : len(fields), "args" : ", ".join(["(jdouble)" + a.name + f[1] for f in fields]) } )
if type_dict[a.ctype]["j_type"] in ('bool', 'int', 'long', 'float', 'double'): if type_dict[a.ctype]["j_type"] in ('bool', 'int', 'long', 'float', 'double'):
...@@ -724,10 +725,10 @@ class JavaWrapperGenerator(object): ...@@ -724,10 +725,10 @@ class JavaWrapperGenerator(object):
# private java NATIVE method decl # private java NATIVE method decl
# e.g. # e.g.
# private static native void add_0(long src1, long src2, long dst, long mask, int dtype); # private static native void add_0(long src1, long src2, long dst, long mask, int dtype);
jn_code.write( Template(\ jn_code.write( Template(
" private static native $type $name($args);\n").substitute(\ " private static native $type $name($args);\n").substitute(
type = type_dict[fi.ctype].get("jn_type", "double[]"), \ type = type_dict[fi.ctype].get("jn_type", "double[]"),
name = fi.jname + '_' + str(suffix_counter), \ name = fi.jname + '_' + str(suffix_counter),
args = ", ".join(["%s %s" % (type_dict[a.ctype]["jn_type"], normalize_field_name(a.name)) for a in jn_args]) args = ", ".join(["%s %s" % (type_dict[a.ctype]["jn_type"], normalize_field_name(a.name)) for a in jn_args])
) ); ) );
...@@ -754,9 +755,9 @@ class JavaWrapperGenerator(object): ...@@ -754,9 +755,9 @@ class JavaWrapperGenerator(object):
ret_type = fi.ctype ret_type = fi.ctype
if fi.ctype.endswith('*'): if fi.ctype.endswith('*'):
ret_type = ret_type[:-1] ret_type = ret_type[:-1]
ret_val = type_dict[ret_type]["j_type"] + " retVal = " ret_val = type_dict[ret_type]["j_type"] + " retVal = " if j_epilogue else "return "
tail = "" tail = ""
ret = "return retVal;" ret = "return retVal;" if j_epilogue else ""
if "v_type" in type_dict[ret_type]: if "v_type" in type_dict[ret_type]:
j_type = type_dict[ret_type]["j_type"] j_type = type_dict[ret_type]["j_type"]
if type_dict[ret_type]["v_type"] in ("Mat", "vector_Mat"): if type_dict[ret_type]["v_type"] in ("Mat", "vector_Mat"):
...@@ -767,70 +768,77 @@ class JavaWrapperGenerator(object): ...@@ -767,70 +768,77 @@ class JavaWrapperGenerator(object):
ret_val = "Mat retValMat = new Mat(" ret_val = "Mat retValMat = new Mat("
j_prologue.append( j_type + ' retVal = new Array' + j_type+'();') j_prologue.append( j_type + ' retVal = new Array' + j_type+'();')
j_epilogue.append('Converters.Mat_to_' + ret_type + '(retValMat, retVal);') j_epilogue.append('Converters.Mat_to_' + ret_type + '(retValMat, retVal);')
ret = "return retVal;"
elif ret_type.startswith("Ptr_"): elif ret_type.startswith("Ptr_"):
ret_val = type_dict[fi.ctype]["j_type"] + " retVal = " + type_dict[ret_type]["j_type"] + ".__fromPtr__(" constructor = type_dict[ret_type]["j_type"] + ".__fromPtr__(";
if j_epilogue:
ret_val = type_dict[fi.ctype]["j_type"] + " retVal = " + constructor
else:
ret_val = "return " + constructor
tail = ")" tail = ")"
elif ret_type == "void": elif ret_type == "void":
ret_val = "" ret_val = ""
ret = "return;" ret = ""
elif ret_type == "": # c-tor elif ret_type == "": # c-tor
if fi.classname and ci.base: if fi.classname and ci.base:
ret_val = "super( " ret_val = "super("
tail = " )" tail = ")"
else: else:
ret_val = "nativeObj = " ret_val = "nativeObj = "
ret = "return;" ret = ""
elif self.isWrapped(ret_type): # wrapped class elif self.isWrapped(ret_type): # wrapped class
ret_val = type_dict[ret_type]["j_type"] + " retVal = new " + self.getClass(ret_type).jname + "(" constructor = self.getClass(ret_type).jname + "(";
if j_epilogue:
ret_val = type_dict[ret_type]["j_type"] + " retVal = new " + constructor
else:
ret_val = "return new " + constructor
tail = ")" tail = ")"
elif "jn_type" not in type_dict[ret_type]: elif "jn_type" not in type_dict[ret_type]:
ret_val = type_dict[fi.ctype]["j_type"] + " retVal = new " + type_dict[ret_type]["j_type"] + "(" constructor = type_dict[ret_type]["j_type"] + "(";
if j_epilogue:
ret_val = type_dict[fi.ctype]["j_type"] + " retVal = new " + constructor
else:
ret_val = "return new " + constructor
tail = ")" tail = ")"
static = "static" static = "static"
if fi.classname: if fi.classname:
static = fi.static static = fi.static
j_code.write( Template(\ j_code.write( Template(
""" public $static $j_type $j_name($j_args) """ public $static$j_type $j_name($j_args) {$prologue
{ $ret_val$jn_name($jn_args_call)$tail;$epilogue$ret
$prologue
$ret_val$jn_name($jn_args_call)$tail;
$epilogue
$ret
} }
""" """
).substitute(\ ).substitute(
ret = ret, \ ret = "\n " + ret if ret else "",
ret_val = ret_val, \ ret_val = ret_val,
tail = tail, \ tail = tail,
prologue = "\n ".join(j_prologue), \ prologue = "\n " + "\n ".join(j_prologue) if j_prologue else "",
epilogue = "\n ".join(j_epilogue), \ epilogue = "\n " + "\n ".join(j_epilogue) if j_epilogue else "",
static=static, \ static = static + " " if static else "",
j_type=type_dict[fi.ctype]["j_type"], \ j_type=type_dict[fi.ctype]["j_type"],
j_name=fi.jname, \ j_name=fi.jname,
j_args=", ".join(j_args), \ j_args=", ".join(j_args),
jn_name=fi.jname + '_' + str(suffix_counter), \ jn_name=fi.jname + '_' + str(suffix_counter),
jn_args_call=", ".join( [a.name for a in jn_args] ),\ jn_args_call=", ".join( [a.name for a in jn_args] ),
) )
) )
# cpp part: # cpp part:
# jni_func(..) { _retval_ = cv_func(..); return _retval_; } # jni_func(..) { _retval_ = cv_func(..); return _retval_; }
ret = "return _retval_;" ret = "return _retval_;" if c_epilogue else ""
default = "return 0;" default = "return 0;"
if fi.ctype == "void": if fi.ctype == "void":
ret = "return;" ret = ""
default = "return;" default = ""
elif not fi.ctype: # c-tor elif not fi.ctype: # c-tor
ret = "return (jlong) _retval_;" ret = "return (jlong) _retval_;"
elif "v_type" in type_dict[fi.ctype]: # c-tor elif "v_type" in type_dict[fi.ctype]: # c-tor
if type_dict[fi.ctype]["v_type"] in ("Mat", "vector_Mat"): if type_dict[fi.ctype]["v_type"] in ("Mat", "vector_Mat"):
ret = "return (jlong) _retval_;" ret = "return (jlong) _retval_;"
else: # returned as jobject
ret = "return _retval_;"
elif fi.ctype == "String": elif fi.ctype == "String":
ret = "return env->NewStringUTF(_retval_.c_str());" ret = "return env->NewStringUTF(_retval_.c_str());"
default = 'return env->NewStringUTF("");' default = 'return env->NewStringUTF("");'
...@@ -853,19 +861,19 @@ class JavaWrapperGenerator(object): ...@@ -853,19 +861,19 @@ class JavaWrapperGenerator(object):
name = prop_name + ";//" name = prop_name + ";//"
cvname = fi.fullName(isCPP=True) cvname = fi.fullName(isCPP=True)
retval = self.fullTypeName(fi.ctype) + " _retval_ = " retval = self.fullTypeName(fi.ctype) + " _retval_ = " if ret else "return "
if fi.ctype == "void": if fi.ctype == "void":
retval = "" retval = ""
elif fi.ctype == "String": elif fi.ctype == "String":
retval = "cv::" + retval retval = "cv::" + self.fullTypeName(fi.ctype) + " _retval_ = "
elif "v_type" in type_dict[fi.ctype]: # vector is returned elif "v_type" in type_dict[fi.ctype]: # vector is returned
retval = type_dict[fi.ctype]['jni_var'] % {"n" : '_ret_val_vector_'} + " = " retval = type_dict[fi.ctype]['jni_var'] % {"n" : '_ret_val_vector_'} + " = "
if type_dict[fi.ctype]["v_type"] in ("Mat", "vector_Mat"): if type_dict[fi.ctype]["v_type"] in ("Mat", "vector_Mat"):
c_epilogue.append("Mat* _retval_ = new Mat();") c_epilogue.append("Mat* _retval_ = new Mat();")
c_epilogue.append(fi.ctype+"_to_Mat(_ret_val_vector_, *_retval_);") c_epilogue.append(fi.ctype+"_to_Mat(_ret_val_vector_, *_retval_);")
else: else:
c_epilogue.append("jobject _retval_ = " + fi.ctype + "_to_List(env, _ret_val_vector_);") c_epilogue.append("return " + fi.ctype + "_to_List(env, _ret_val_vector_);")
if len(fi.classname)>0: if fi.classname:
if not fi.ctype: # c-tor if not fi.ctype: # c-tor
retval = fi.fullClass(isCPP=True) + "* _retval_ = " retval = fi.fullClass(isCPP=True) + "* _retval_ = "
cvname = "new " + fi.fullClass(isCPP=True) cvname = "new " + fi.fullClass(isCPP=True)
...@@ -873,9 +881,9 @@ class JavaWrapperGenerator(object): ...@@ -873,9 +881,9 @@ class JavaWrapperGenerator(object):
cvname = fi.fullName(isCPP=True) cvname = fi.fullName(isCPP=True)
else: else:
cvname = ("me->" if not self.isSmartClass(ci) else "(*me)->") + name cvname = ("me->" if not self.isSmartClass(ci) else "(*me)->") + name
c_prologue.append(\ c_prologue.append(
"%(cls)s* me = (%(cls)s*) self; //TODO: check for NULL" \ "%(cls)s* me = (%(cls)s*) self; //TODO: check for NULL"
% { "cls" : self.smartWrap(ci, fi.fullClass(isCPP=True))} \ % { "cls" : self.smartWrap(ci, fi.fullClass(isCPP=True))}
) )
cvargs = [] cvargs = []
for a in args: for a in args:
...@@ -898,7 +906,7 @@ class JavaWrapperGenerator(object): ...@@ -898,7 +906,7 @@ class JavaWrapperGenerator(object):
rtype = type_dict[fi.ctype].get("jni_type", "jdoubleArray") rtype = type_dict[fi.ctype].get("jni_type", "jdoubleArray")
clazz = ci.jname clazz = ci.jname
cpp_code.write ( Template( \ cpp_code.write ( Template(
""" """
${namespace} ${namespace}
...@@ -909,37 +917,34 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_${clazz}_$fname ...@@ -909,37 +917,34 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_${clazz}_$fname
{ {
static const char method_name[] = "$module::$fname()"; static const char method_name[] = "$module::$fname()";
try { try {
LOGD("%s", method_name); LOGD("%s", method_name);$prologue
$prologue $retval$cvname($cvargs);$epilogue$ret
$retval$cvname( $cvargs );
$epilogue$ret
} catch(const std::exception &e) { } catch(const std::exception &e) {
throwJavaException(env, &e, method_name); throwJavaException(env, &e, method_name);
} catch (...) { } catch (...) {
throwJavaException(env, 0, method_name); throwJavaException(env, 0, method_name);
} }$default
$default
} }
""" ).substitute( \ """ ).substitute(
rtype = rtype, \ rtype = rtype,
module = self.module.replace('_', '_1'), \ module = self.module.replace('_', '_1'),
clazz = clazz.replace('_', '_1'), \ clazz = clazz.replace('_', '_1'),
fname = (fi.jname + '_' + str(suffix_counter)).replace('_', '_1'), \ fname = (fi.jname + '_' + str(suffix_counter)).replace('_', '_1'),
args = ", ".join(["%s %s" % (type_dict[a.ctype].get("jni_type"), a.name) for a in jni_args]), \ args = ", ".join(["%s %s" % (type_dict[a.ctype].get("jni_type"), a.name) for a in jni_args]),
argst = ", ".join([type_dict[a.ctype].get("jni_type") for a in jni_args]), \ argst = ", ".join([type_dict[a.ctype].get("jni_type") for a in jni_args]),
prologue = "\n ".join(c_prologue), \ prologue = "\n " + "\n ".join(c_prologue) if c_prologue else "",
epilogue = " ".join(c_epilogue) + ("\n " if c_epilogue else ""), \ epilogue = "\n " + "\n ".join(c_epilogue) if c_epilogue else "",
ret = ret, \ ret = "\n " + ret if ret else "",
cvname = cvname, \ cvname = cvname,
cvargs = ", ".join(cvargs), \ cvargs = " " + ", ".join(cvargs) + " " if cvargs else "",
default = default, \ default = "\n " + default if default else "",
retval = retval, \ retval = retval,
namespace = ('using namespace ' + ci.namespace.replace('.', '::') + ';') if ci.namespace else '' namespace = ('using namespace ' + ci.namespace.replace('.', '::') + ';') if ci.namespace else ''
) ) ) )
# adding method signature to dictionarry # adding method signature to dictionary
j_signatures.append(j_signature) j_signatures.append(j_signature)
# processing args with default values # processing args with default values
...@@ -1036,7 +1041,7 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_${clazz}_$fname ...@@ -1036,7 +1041,7 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_${clazz}_$fname
""" ) """ )
# native support for java finalize() # native support for java finalize()
ci.cpp_code.write( \ ci.cpp_code.write(
""" """
// //
// native support for java finalize() // native support for java finalize()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment