From 3a0d6f1a7e981a5128e36e13d231b58d082a6ff0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 25 Aug 2004 21:32:27 +0000 Subject: [PATCH] varin enum SWIGTYPE mods to handle unnamed enums git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6149 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/perl5/perl5.swg | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/perl5/perl5.swg b/Lib/perl5/perl5.swg index e6854c7d9..6d35e8bc4 100644 --- a/Lib/perl5/perl5.swg +++ b/Lib/perl5/perl5.swg @@ -225,7 +225,7 @@ /* Variable input */ -%typemap(varin) int, short, long, signed char, bool, enum SWIGTYPE +%typemap(varin) int, short, long, signed char, bool "$1 = ($1_ltype) SvIV($input);"; %typemap(varin) unsigned int, unsigned short, unsigned long, unsigned char @@ -361,8 +361,12 @@ %typemap(varin,warning="462: Unable to set variable of type char []") char [] { croak("Variable $symname is read-only."); } -%typemap(varin) enum SWIGTYPE - "$1 = ($1_type) SvIV($input);"; +%typemap(varin) enum SWIGTYPE { + if (sizeof(int) != sizeof($1)) { + croak("enum variable '$name' can not be set."); + } + *(int *)(void *)&($1) = SvIV($input); +} /* --- Typemaps for variable output --- */