various tweaks
toString() method support git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5955 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
92fd36fc00
commit
bdbbef48a8
1 changed files with 18 additions and 11 deletions
|
|
@ -17,17 +17,17 @@
|
||||||
|
|
||||||
%typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE ""
|
%typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE ""
|
||||||
|
|
||||||
|
%typemap(throws) enum SWIGTYPE %{
|
||||||
|
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown");
|
||||||
|
%}
|
||||||
|
|
||||||
%typemap(javain) enum SWIGTYPE "$javainput.swigValue()"
|
%typemap(javain) enum SWIGTYPE "$javainput.swigValue()"
|
||||||
%typemap(javaout) enum SWIGTYPE {
|
%typemap(javaout) enum SWIGTYPE {
|
||||||
return $javaclassname.swigToEnum($jnicall);
|
return $javaclassname.swigToEnum($jnicall);
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(throws) enum SWIGTYPE {
|
|
||||||
SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown");
|
|
||||||
}
|
|
||||||
|
|
||||||
// '$static' will be replaced with either 'static' or nothing depending on whether the enum is an inner Java class or not
|
// '$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(javaclassmodifiers) enum SWIGTYPE "public final $static class"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The swigToEnum method is used to find the Java enum from a C++ enum integer value. The default one here takes
|
* The swigToEnum method is used to find the Java enum from a C++ enum integer value. The default one here takes
|
||||||
|
|
@ -41,27 +41,34 @@
|
||||||
return swigValue;
|
return swigValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return swigName;
|
||||||
|
}
|
||||||
|
|
||||||
public static $javaclassname swigToEnum(int swigValue) {
|
public static $javaclassname swigToEnum(int swigValue) {
|
||||||
if (swigValue < swigValues.length && swigValues[swigValue].swigValue == swigValue)
|
if (swigValue < swigValues.length && swigValues[swigValue].swigValue == swigValue)
|
||||||
return swigValues[swigValue];
|
return swigValues[swigValue];
|
||||||
for (int i = 0; i<swigValues.length; i++)
|
for (int i = 0; i < swigValues.length; i++)
|
||||||
if (swigValues[i].swigValue == swigValue)
|
if (swigValues[i].swigValue == swigValue)
|
||||||
return swigValues[i];
|
return swigValues[i];
|
||||||
throw new IllegalArgumentException("No enum " + $javaclassname.class + " with value " + swigValue);
|
throw new IllegalArgumentException("No enum " + $javaclassname.class + " with value " + swigValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private $javaclassname() {
|
private $javaclassname(String swigName) {
|
||||||
this.swigValue = next++;
|
this.swigName = swigName;
|
||||||
|
this.swigValue = swigNext++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private $javaclassname(int swigValue) {
|
private $javaclassname(String swigName, int swigValue) {
|
||||||
|
this.swigName = swigName;
|
||||||
this.swigValue = swigValue;
|
this.swigValue = swigValue;
|
||||||
next = swigValue+1;
|
swigNext = swigValue+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static $javaclassname[] swigValues = { $enumvalues };
|
private static $javaclassname[] swigValues = { $enumvalues };
|
||||||
private static int next = 0;
|
private static int swigNext = 0;
|
||||||
private final int swigValue;
|
private final int swigValue;
|
||||||
|
private final String swigName;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%javaenum(typesafe);
|
%javaenum(typesafe);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue