swig/java: reduce wrapper function code duplication

define a macro to emit the wrapper code

Change-Id: I672416016162d6d9ce6f455d224044e0837e3ace
(cherry picked from commit a5c297c842)
This commit is contained in:
James Zern 2013-05-20 17:03:35 -07:00
parent 6fe536f4ba
commit 6b931875ac
2 changed files with 23 additions and 45 deletions

View File

@ -273,57 +273,35 @@ LOSSLESS_WRAPPER(WebPEncodeLosslessBGRA)
%pragma(java) modulecode=%{
private static final int UNUSED = 1;
private static int outputSize[] = { 0 };
%}
public static byte[] WebPEncodeRGB(byte[] rgb,
int width, int height, int stride,
float quality_factor) {
return wrap_WebPEncodeRGB(
%define CALL_ENCODE_LOSSY_WRAPPER(func)
%pragma(java) modulecode=%{
public static byte[] func(
byte[] rgb, int width, int height, int stride, float quality_factor) {
return wrap_##func(
rgb, UNUSED, UNUSED, outputSize, width, height, stride, quality_factor);
}
%}
%enddef
public static byte[] WebPEncodeBGR(byte[] bgr,
int width, int height, int stride,
float quality_factor) {
return wrap_WebPEncodeBGR(
bgr, UNUSED, UNUSED, outputSize, width, height, stride, quality_factor);
}
public static byte[] WebPEncodeRGBA(byte[] rgba,
int width, int height, int stride,
float quality_factor) {
return wrap_WebPEncodeRGBA(
rgba, UNUSED, UNUSED, outputSize, width, height, stride, quality_factor);
}
public static byte[] WebPEncodeBGRA(byte[] bgra,
int width, int height, int stride,
float quality_factor) {
return wrap_WebPEncodeBGRA(
bgra, UNUSED, UNUSED, outputSize, width, height, stride, quality_factor);
}
public static byte[] WebPEncodeLosslessRGB(
%define CALL_ENCODE_LOSSLESS_WRAPPER(func)
%pragma(java) modulecode=%{
public static byte[] func(
byte[] rgb, int width, int height, int stride) {
return wrap_WebPEncodeLosslessRGB(
return wrap_##func(
rgb, UNUSED, UNUSED, outputSize, width, height, stride);
}
public static byte[] WebPEncodeLosslessBGR(
byte[] bgr, int width, int height, int stride) {
return wrap_WebPEncodeLosslessBGR(
bgr, UNUSED, UNUSED, outputSize, width, height, stride);
}
public static byte[] WebPEncodeLosslessRGBA(
byte[] rgba, int width, int height, int stride) {
return wrap_WebPEncodeLosslessRGBA(
rgba, UNUSED, UNUSED, outputSize, width, height, stride);
}
public static byte[] WebPEncodeLosslessBGRA(
byte[] bgra, int width, int height, int stride) {
return wrap_WebPEncodeLosslessBGRA(
bgra, UNUSED, UNUSED, outputSize, width, height, stride);
}
%}
%enddef
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeRGB)
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeRGBA)
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeBGR)
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeBGRA)
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessRGB)
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessRGBA)
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessBGR)
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessBGRA)
#endif /* SWIGJAVA */

Binary file not shown.