From 6b931875acfd54ef35de6926c5cf4552e06e8443 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 20 May 2013 17:03:35 -0700 Subject: [PATCH] swig/java: reduce wrapper function code duplication define a macro to emit the wrapper code Change-Id: I672416016162d6d9ce6f455d224044e0837e3ace (cherry picked from commit a5c297c842c96e899725328378ff14400176458b) --- swig/libwebp.i | 68 ++++++++++++++++------------------------------- swig/libwebp.jar | Bin 2143 -> 3099 bytes 2 files changed, 23 insertions(+), 45 deletions(-) diff --git a/swig/libwebp.i b/swig/libwebp.i index 0cb7ccce..b541c3f9 100644 --- a/swig/libwebp.i +++ b/swig/libwebp.i @@ -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 */ diff --git a/swig/libwebp.jar b/swig/libwebp.jar index 602f037ce69ec88363f3f4f95526f880da7c8b3d..6cc574b2d8d163b9aade3b5857e0bc646398ea94 100644 GIT binary patch literal 3099 zcmaJ@2{@E{7k|mVT+)QG-z-@N$r{VjYiqBSEizdG?!48n37^L zS;jJ!u1jS%Ql@OBRKA(&3w?ZNp7(kF&%Eb%-t(T{d(QbGV7pjA00##L5O%KC1lVMp z01IGcZfC3lg&$G<+5rH&00fMkgWQmx8=6ffi(-6Fbif4V z1$=yQ(Ko^qwTQ;g#&H^5%axh^X%N+LY$;#wIse!~Z;Pc_=0i(K2GsRKJ-SG~HR{`* zQ9$mFYB9SySS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