moving more enum typemaps here
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6419 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c0dc57464a
commit
1fc46dfc1f
1 changed files with 7 additions and 4 deletions
|
|
@ -2,21 +2,24 @@
|
|||
* Enums
|
||||
* ------------------------------------------------------------ */
|
||||
%apply int { enum SWIGTYPE };
|
||||
/* this doesn't work now, you need to redefined it for each enum. */
|
||||
%apply const int& { const enum SWIGTYPE& };
|
||||
|
||||
|
||||
%typemap(varin,fragment=SWIG_AsVal_frag(int)) enum SWIGTYPE
|
||||
{
|
||||
if (sizeof(int) != sizeof($1)) {
|
||||
PyErr_SetString(PyExc_AttributeError, "enum variable '$name' can not be set");
|
||||
return 1;
|
||||
}
|
||||
if (!SWIG_AsVal(int)($input, (int*)(void*)&($1))) {
|
||||
if (!SWIG_AsVal(int)($input, (int*)(void*)(&$1))) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
%define ENUM_OUT_TYPEMAP(from_meth,pyfrag)
|
||||
/*
|
||||
typemaps needed due to unnamed enums
|
||||
*/
|
||||
%define PY_ENUM_OUT_TYPEMAPS(from_meth,pyfrag)
|
||||
%typemap(out,fragment=pyfrag) enum SWIGTYPE
|
||||
"$result = from_meth(($1));";
|
||||
%typemap(out,fragment=pyfrag) const enum SWIGTYPE&
|
||||
|
|
@ -34,7 +37,7 @@
|
|||
SWIG_fail;";
|
||||
%enddef
|
||||
|
||||
ENUM_OUT_TYPEMAP(SWIG_From(int),SWIG_From_frag(int));
|
||||
PY_ENUM_OUT_TYPEMAPS(SWIG_From(int),SWIG_From_frag(int));
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue