swig: file reorganization

Rather than %include'ing decode.h and potentially pickup new
(unsupported functions), explicitly list the desired functions as with
encode.
Reorganize a bit to contain most of the language specific additions to
one area. This fixes the visibility of the wrap_* functions in java. The
method modifiers need to come before the function prototypes.

Change-Id: I595df4d1a60edcb263923b5a2621879d3b6233cf
This commit is contained in:
James Zern 2011-06-17 14:26:06 -07:00
parent 7fc7e0d9eb
commit 00d9d6807c
3 changed files with 266 additions and 276 deletions

View File

@ -21,34 +21,19 @@
%include "constraints.i"
%include "typemaps.i"
#ifdef SWIGJAVA
%include "arrays_java.i";
%include "enums.swg" /*NB: requires JDK-1.5+
See: http://www.swig.org/Doc1.3/Java.html#enumerations */
// map uint8_t* such that a byte[] is used
// this will generate a few spurious warnings in the wrapper code
%apply signed char[] { uint8_t * }
#endif /* SWIGJAVA */
//------------------------------------------------------------------------------
// Decoder specific
%ignore WEBP_WEBP_DECODE_H_;
// FIXME for these to be available returned_buffer_size() would need to be
// made more intelligent.
%ignore WebPDecodeRGBInto;
%ignore WebPDecodeYUV;
%ignore WebPDecodeRGBAInto;
%ignore WebPDecodeBGRInto;
%ignore WebPDecodeBGRAInto;
%ignore WebPDecodeYUVInto;
// incremental decoding
%ignore WEBP_CSP_MODE;
%ignore VP8StatusCode;
%ignore WebPIDecGetYUV;
%ignore WebPINew;
%ignore WebPIDecoder;
%ignore WebPIAppend;
%ignore WebPIDecGetRGB;
%ignore WebPIDelete;
%ignore WebPINewRGB;
%ignore WebPINewYUV;
%ignore WebPIUpdate;
%ignore WebPInitCustomIo;
%ignore WebPInitDecParams;
%apply int *OUTPUT { int *width, int *height }
%apply int { uint32_t data_size }
%apply Number NONNEGATIVE { uint32_t data_size }
@ -61,34 +46,27 @@
%newobject WebPDecodeBGRA;
%typemap(newfree) uint8_t* "free($1);"
int WebPGetDecoderVersion(void);
int WebPGetInfo(const uint8_t* data, uint32_t data_size,
int *width, int *height);
uint8_t* WebPDecodeRGB(const uint8_t* data, uint32_t data_size,
int *width, int *height);
uint8_t* WebPDecodeRGBA(const uint8_t* data, uint32_t data_size,
int *width, int *height);
uint8_t* WebPDecodeBGR(const uint8_t* data, uint32_t data_size,
int *width, int *height);
uint8_t* WebPDecodeBGRA(const uint8_t* data, uint32_t data_size,
int *width, int *height);
//------------------------------------------------------------------------------
// Encoder specific
int WebPGetEncoderVersion(void);
#ifdef SWIGJAVA
%include "arrays_java.i";
%include "enums.swg" /*NB: requires JDK-1.5+
See: http://www.swig.org/Doc1.3/Java.html#enumerations */
//------------------------------------------------------------------------------
// Wrapper code additions
// map uint8_t* such that a byte[] is used
// this will generate a few spurious warnings in the wrapper code
%apply signed char[] { uint8_t * }
%{
/* Work around broken gcj jni.h */
#ifdef __GCJ_JNI_H__
# undef JNIEXPORT
# define JNIEXPORT
# undef JNICALL
# define JNICALL
#endif
%}
#endif
/*
* Wrapper code additions
*/
%{
#include "webp/decode.h"
#include "webp/encode.h"
@ -158,6 +136,14 @@ static uint8_t* encode(const uint8_t* rgb,
%newobject wrap_WebPEncodeRGBA;
%newobject wrap_WebPEncodeBGRA;
#ifdef SWIGJAVA
// There's no reason to call these directly
%javamethodmodifiers wrap_WebPEncodeRGB "private";
%javamethodmodifiers wrap_WebPEncodeBGR "private";
%javamethodmodifiers wrap_WebPEncodeRGBA "private";
%javamethodmodifiers wrap_WebPEncodeBGRA "private";
#endif /* SWIGJAVA */
%inline %{
// Changes the return type of WebPEncode* to more closely match Decode*.
// This also makes it easier to wrap the output buffer in a native type rather
@ -193,12 +179,19 @@ static uint8_t* wrap_WebPEncodeBGRA(
}
%}
//------------------------------------------------------------------------------
// Language specific
#ifdef SWIGJAVA
// There's no reason to call these directly
%javamethodmodifiers wrap_WebPEncodeRGB "private";
%javamethodmodifiers wrap_WebPEncodeBGR "private";
%javamethodmodifiers wrap_WebPEncodeRGBA "private";
%javamethodmodifiers wrap_WebPEncodeBGRA "private";
%{
/* Work around broken gcj jni.h */
#ifdef __GCJ_JNI_H__
# undef JNIEXPORT
# define JNIEXPORT
# undef JNICALL
# define JNICALL
#endif
%}
%pragma(java) modulecode=%{
private static final int UNUSED = 1;
@ -233,6 +226,3 @@ static uint8_t* wrap_WebPEncodeBGRA(
}
%}
#endif /* SWIGJAVA */
// All functions, constants, etc. not named above in %ignore will be wrapped
%include "webp/decode.h"

Binary file not shown.

View File

@ -808,15 +808,6 @@ jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) {
#endif
/* Work around broken gcj jni.h */
#ifdef __GCJ_JNI_H__
# undef JNIEXPORT
# define JNIEXPORT
# undef JNICALL
# define JNICALL
#endif
#include "webp/decode.h"
#include "webp/encode.h"
@ -906,222 +897,19 @@ static uint8_t* wrap_WebPEncodeBGRA(
}
/* Work around broken gcj jni.h */
#ifdef __GCJ_JNI_H__
# undef JNIEXPORT
# define JNIEXPORT
# undef JNICALL
# define JNICALL
#endif
#ifdef __cplusplus
extern "C" {
#endif
SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_WebPGetEncoderVersion(JNIEnv *jenv, jclass jcls) {
jint jresult = 0 ;
int result;
(void)jenv;
(void)jcls;
result = (int)WebPGetEncoderVersion();
jresult = (jint)result;
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRGB(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7, jfloat jarg8) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
float arg8 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
arg8 = (float)jarg8;
result = (uint8_t *)wrap_WebPEncodeRGB((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBGR(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7, jfloat jarg8) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
float arg8 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
arg8 = (float)jarg8;
result = (uint8_t *)wrap_WebPEncodeBGR((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRGBA(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7, jfloat jarg8) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
float arg8 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
arg8 = (float)jarg8;
result = (uint8_t *)wrap_WebPEncodeRGBA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBGRA(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7, jfloat jarg8) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
float arg8 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
arg8 = (float)jarg8;
result = (uint8_t *)wrap_WebPEncodeBGRA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_WebPGetDecoderVersion(JNIEnv *jenv, jclass jcls) {
jint jresult = 0 ;
int result;
@ -1448,6 +1236,218 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeBGRA(JNI
}
SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_WebPGetEncoderVersion(JNIEnv *jenv, jclass jcls) {
jint jresult = 0 ;
int result;
(void)jenv;
(void)jcls;
result = (int)WebPGetEncoderVersion();
jresult = (jint)result;
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRGB(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7, jfloat jarg8) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
float arg8 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
arg8 = (float)jarg8;
result = (uint8_t *)wrap_WebPEncodeRGB((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBGR(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7, jfloat jarg8) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
float arg8 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
arg8 = (float)jarg8;
result = (uint8_t *)wrap_WebPEncodeBGR((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRGBA(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7, jfloat jarg8) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
float arg8 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
arg8 = (float)jarg8;
result = (uint8_t *)wrap_WebPEncodeRGBA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBGRA(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jint jarg3, jintArray jarg4, jint jarg5, jint jarg6, jint jarg7, jfloat jarg8) {
jbyteArray jresult = 0 ;
uint8_t *arg1 = (uint8_t *) 0 ;
int *arg2 = (int *) 0 ;
int *arg3 = (int *) 0 ;
int *arg4 = (int *) 0 ;
int arg5 ;
int arg6 ;
int arg7 ;
float arg8 ;
jbyte *jarr1 ;
int temp4 ;
uint8_t *result = 0 ;
(void)jenv;
(void)jcls;
if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0;
arg2 = (int *)&jarg2;
arg3 = (int *)&jarg3;
{
if (!jarg4) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
return 0;
}
if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
return 0;
}
arg4 = &temp4;
}
arg5 = (int)jarg5;
arg6 = (int)jarg6;
arg7 = (int)jarg7;
arg8 = (float)jarg8;
result = (uint8_t *)wrap_WebPEncodeBGRA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically);
SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1);
{
jint jvalue = (jint)temp4;
(*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue);
}
free(arg1);
free(result);
return jresult;
}
#ifdef __cplusplus
}
#endif