Hi Swiggers,

I have a method which is declared in an interface header file as follows:

      virtual void SetFromRawBuffer(const unsigned char * rawImageData, Format format, int width, int height, Origin origin) = 0;

 

To swig this into JAVA, I am just doing the following:

 

      %include "arrays_java.i"

      %apply signed char * INPUT{ unsigned char *rawImageData };

 

This results in the following output (with minor modifications), which fails to compile because temp2 is undeclared in the function.

SWIGEXPORT void JNICALL Java_LIBRARY_NAME_MODIFIED_HERE_IImage_1SetFromRawBuffer(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jbyte jarg2, jint jarg3, jint jarg4, jint jarg5, jint jarg6) {

  CompanyName::Library::IImage *arg1 = (CompanyName::Library::IImage *) 0 ;

  unsigned char *arg2 = (unsigned char *) 0 ;

  CompanyName::Library::IImage::Format arg3 ;

  int arg4 ;

  int arg5 ;

  CompanyName::Library::IImage::Origin arg6 ;

 

  (void)jenv;

  (void)jcls;

  (void)jarg1_;

  arg1 = *(CompanyName::Library::IImage **)&jarg1;

  arg2 = (unsigned char *)&jarg2;

  arg3 = (CompanyName::Library::IImage::Format)jarg3;

  arg4 = (int)jarg4;

  arg5 = (int)jarg5;

  arg6 = (CompanyName::Library::IImage::Origin)jarg6;

  (arg1)->SetFromRawBuffer((unsigned char const *)arg2,arg3,arg4,arg5,arg6);

  {

    jbyte jvalue = (jbyte)temp2;

    jenv->SetByteArrayRegion(jarg2, 0, 1, &jvalue);

  }

 

}

 

If I swig it with

      %apply signed char * INPUT{ unsigned char *rawImageData };

Or

 

      %apply signed char * { unsigned char *rawImageData };

then it compiles, but it seems to me that I want to use INPUT, since that should theoretically avoid an extra copy. It seems to me that the entire last set of braces in the swig generated code above just shouldn’t be there. Is this a bug in swig or am I doing something wrong?

 

Thanks,

Liron Kopinsky