add cast to work with SwigValueWrapper and write the out enum types appart, as needed

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6375 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-10-08 09:11:09 +00:00
commit cee113efe7
2 changed files with 33 additions and 12 deletions

View file

@ -2,6 +2,8 @@
* 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
{
@ -14,8 +16,28 @@
}
}
%define ENUM_OUT_TYPEMAP(from_meth,pyfrag)
%typemap(out,fragment=pyfrag) enum SWIGTYPE
"$result = from_meth(($1));";
%typemap(out,fragment=pyfrag) const enum SWIGTYPE&
"$result = from_meth((*$1));";
%typemap(varout,fragment=pyfrag) enum SWIGTYPE, const enum SWIGTYPE&
"$result = from_meth($1);";
%typemap(constcode,fragment=pyfrag) enum SWIGTYPE
"PyDict_SetItemString(d,\"$symname\", from_meth($value));";
%typemap(directorin,fragment=pyfrag) enum SWIGTYPE *DIRECTORIN
"$input = from_meth(*$1_name);";
%typemap(directorin,fragment=pyfrag) enum SWIGTYPE, const enum SWIGTYPE&
"$input = from_meth($1_name);";
%typemap(throws,fragment=pyfrag) enum SWIGTYPE
"PyErr_SetObject(PyExc_RuntimeError, from_meth($1));
SWIG_fail;";
%enddef
ENUM_OUT_TYPEMAP(SWIG_From(int),SWIG_From_frag(int));
/* this doesn't work now, you need to redefined it for each enum. */
%apply const int& { const enum SWIGTYPE& };