Enum typemaps taken out of java.swg
New typemap files for the different C/C++ to Java enum wrapping approaches. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5921 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
064082e9b5
commit
990156dff1
5 changed files with 234 additions and 19 deletions
40
Lib/java/enumtypeunsafe.swg
Normal file
40
Lib/java/enumtypeunsafe.swg
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Include this file in order for C/C++ enums to be wrapped by integers values.
|
||||
* Each enum has an equivalent class named after the enum and the enum items are
|
||||
* wrapped by constant integers within this class. The enum items are not
|
||||
* typesafe as they are all integers.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(jni) enum SWIGTYPE "jint"
|
||||
%typemap(jtype) enum SWIGTYPE "int"
|
||||
%typemap(jstype) enum SWIGTYPE "int"
|
||||
|
||||
%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
|
||||
%typemap(out) enum SWIGTYPE %{ $result = (jint)$1; %}
|
||||
|
||||
%typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;"
|
||||
%typemap(javadirectorin) enum SWIGTYPE "$jniinput"
|
||||
%typemap(javadirectorout) enum SWIGTYPE "$javacall"
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE ""
|
||||
|
||||
%typemap(javain) enum SWIGTYPE "$javainput.swigValue()"
|
||||
%typemap(javaout) enum SWIGTYPE {
|
||||
return $javaclassname.swigToEnum($jnicall);
|
||||
}
|
||||
|
||||
%typemap(throws) enum SWIGTYPE {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown");
|
||||
}
|
||||
|
||||
%typemap(javain) enum SWIGTYPE "$javainput"
|
||||
%typemap(javaout) enum SWIGTYPE {
|
||||
return $jnicall;
|
||||
}
|
||||
|
||||
// '$static' will be replaced with either 'static' or nothing depending on whether the enum is an inner Java class or not
|
||||
%typemap(javaclassmodifiers) enum SWIGTYPE "public $static class"
|
||||
%typemap(javagetcptr) enum SWIGTYPE ""
|
||||
|
||||
%javaenum(typeunsafe);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue