Error while using enum datatype as a input pramaeter for Java using SWIG

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Error while using enum datatype as a input pramaeter for Java using SWIG

nazneen
This post has NOT been accepted by the mailing list yet.
I am working on creating SWIG wrappers for Java.
I have one project of C++ dll which we want to use in Java code. In  dll i am using third party Libs and .h file. In .h file there is one function which has enum as a input parameter.

In order to use use it in java I need to create java wrappers for this dll.

To use addDemo function via dll i have defined following interface file for SWIG:

%module Mydemo
%{
#include "Demo.h"
extern int addDemo(Demo::KeyType_t type, unsigned char *data, unsigned int size);
%}
%include "Demo.h"
extern int addDemo(Demo::KeyType_t type, unsigned char *data, unsigned int size);


After executing SWIG command, wrap.cxx file has been genearted and this file I am importing it in dll project.

following is the wrap.cxx file for addDemo function:
SWIGEXPORT jint JNICALL Java_MyDemoNI_addDemo(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  jint jresult = 0 ;
  MyDemo::KeyType_t arg1 ;
  unsigned char *arg2 = (unsigned char *) 0 ;
  unsigned int arg3 ;
  MyDemo::KeyType_t *argp1 ;
  int result;
 
  (void)jenv;
  (void)jcls;
  argp1 = *(MyDemo::KeyType_t **)&jarg1;
  if (!argp1) {
    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null MyDemo::KeyType_t");
    return 0;
  }
  arg1 = *argp1;
  arg2 = *(unsigned char **)&jarg2;
  arg3 = (unsigned int)jarg3;
  result = (int)addDemo(arg1,arg2,arg3);
  jresult = (jint)result;
  return jresult;
}


#ifdef __cplusplus
}
#endif



As addDemo is an static method in .h file so I have to access it by class name. So while accessing enaum like this:
MyDemo::KeyType_t


I am getting errors as –
Error     1          error C2653: 'MyDemo' : is not a class or namespace name _wrap.cxx
 
Error     2          error C2065: 'KeyType_t' : undeclared identifier    wrap.cxx

Error     11         error C2065: 'argp1' : undeclared identifier wrap.cxx        

Error     8          error C2065: 'arg1' : undeclared identifier            wrap.cxx
           
 


Loading...