diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2010-05-14 18:46:20 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2010-05-14 18:46:20 +0000 |
commit | 8a169eb0cb80b85d656f728b6659c6937dca9148 (patch) | |
tree | d9181d6e9d0739d815ab92e34f46975a47f7b26d /Source | |
parent | 227f2e2e0aa07b750ae976c3dda35fb442769a8a (diff) | |
download | swig-8a169eb0cb80b85d656f728b6659c6937dca9148.tar.gz |
Fix wrapping of C++ enum boolean values
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12028 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CParse/parser.y | 6 | ||||
-rw-r--r-- | Source/Modules/csharp.cxx | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 1990a66c6..6e41fa565 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -5601,7 +5601,7 @@ edecl : ID { Setattr($$,"type",type); Delete(type); } else { - SwigType *type = NewSwigType(T_INT); + SwigType *type = NewSwigType($3.type == T_BOOL ? T_BOOL : T_INT); Setattr($$,"value",$1); Setattr($$,"type",type); Delete(type); @@ -5617,8 +5617,8 @@ etype : expr { ($$.type != T_LONG) && ($$.type != T_ULONG) && ($$.type != T_SHORT) && ($$.type != T_USHORT) && ($$.type != T_SCHAR) && ($$.type != T_UCHAR) && - ($$.type != T_CHAR)) { - Swig_error(cparse_file,cparse_line,"Type error. Expecting an int\n"); + ($$.type != T_CHAR) && ($$.type != T_BOOL)) { + Swig_error(cparse_file,cparse_line,"Type error. Expecting an integral type\n"); } if ($$.type == T_CHAR) $$.type = T_INT; } diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index f70403326..3dd51aabf 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1282,6 +1282,13 @@ public: // Note that this is used in enumValue() amongst other places Setattr(n, "value", tmpValue); + // Deal with enum values that are bools + if (SwigType_type(Getattr(n, "type")) == T_BOOL) { + String *boolValue = NewStringf("%s ? 1 : 0", Getattr(n, "enumvalue")); + Setattr(n, "enumvalue", boolValue); + Delete(boolValue); + } + { EnumFeature enum_feature = decodeEnumFeature(parent); |