mirror of https://github.com/swig/swig
SF bug #3195112 - fix wrapping of enums that are type char
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12557 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ae6aef5d8f
commit
b13ec94386
|
@ -5,8 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 2.0.3 (in progress)
|
||||
===========================
|
||||
|
||||
2011-03-26: wsfulton
|
||||
[C#, Java] SF bug #3195112 - fix wrapping of enums that are type char, for example:
|
||||
enum { X = 'X'; }
|
||||
|
||||
2011-03-21: vadz
|
||||
[build] Allow setting PCRE_CFLAGS and PCRE_LIBS to override the values returned by
|
||||
Allow setting PCRE_CFLAGS and PCRE_LIBS during configuration to override the values returned by
|
||||
pcre-config, e.g. to allow using a static version of PCRE library.
|
||||
|
||||
2011-03-17: wsfulton
|
||||
|
|
|
@ -405,6 +405,28 @@ public class runme {
|
|||
if ((int)enum_thorough.repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed");
|
||||
if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeint) != 10) throw new Exception("differentTypes 1 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typechar) != 'C') throw new Exception("differentTypes 5 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough.global_typeint;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough.global_typeboolfalse;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough.global_typebooltrue;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough.global_typebooltwo;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough.global_typechar;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough.global_typedefaultint;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -405,6 +405,28 @@ public class runme {
|
|||
if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed");
|
||||
if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeint) != 10) throw new Exception("differentTypes 1 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typechar) != 'C') throw new Exception("differentTypes 5 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough_simple.global_typeint;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough_simple.global_typeboolfalse;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough_simple.global_typebooltrue;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough_simple.global_typebooltwo;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough_simple.global_typechar;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough_simple.global_typedefaultint;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -405,6 +405,28 @@ public class runme {
|
|||
if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed");
|
||||
if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeint).swigValue != 10) throw new Exception("differentTypes 1 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltrue).swigValue != 1) throw new Exception("differentTypes 2 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltwo).swigValue != 2) throw new Exception("differentTypes 3 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeboolfalse).swigValue != 0) throw new Exception("differentTypes 4 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typechar).swigValue != (int)'C') throw new Exception("differentTypes 5 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typedefaultint).swigValue != (int)'D') throw new Exception("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough_typesafe.global_typeint;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typeboolfalse;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typebooltrue;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typebooltwo;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typechar;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typedefaultint;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -537,7 +537,6 @@ IgnoreTest::IgnoreE ignoreETest(IgnoreTest::IgnoreE n) { return n; }
|
|||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace RepeatSpace {
|
||||
typedef enum
|
||||
{
|
||||
|
@ -550,6 +549,58 @@ typedef enum
|
|||
} repeat;
|
||||
repeat repeatTest(repeat e) { return e; }
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
namespace DifferentSpace {
|
||||
enum DifferentTypes {
|
||||
typeint = 10,
|
||||
typeboolfalse = false,
|
||||
typebooltrue = true,
|
||||
typebooltwo,
|
||||
typechar = 'C',
|
||||
typedefaultint
|
||||
};
|
||||
DifferentTypes differentTypesTest(DifferentTypes n) { return n; }
|
||||
|
||||
enum {
|
||||
global_typeint = 10,
|
||||
global_typeboolfalse = false,
|
||||
global_typebooltrue = true,
|
||||
global_typebooltwo,
|
||||
global_typechar = 'C',
|
||||
global_typedefaultint
|
||||
};
|
||||
int globalDifferentTypesTest(int n) { return n; }
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA)
|
||||
%javaconst(0);
|
||||
#elif defined(SWIGCSHARP)
|
||||
%csconst(0);
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
namespace DifferentSpace {
|
||||
enum DifferentTypesNoConst {
|
||||
typeint_noconst = 10,
|
||||
typeboolfalse_noconst = false,
|
||||
typebooltrue_noconst = true,
|
||||
typebooltwo_noconst,
|
||||
typechar_noconst = 'C',
|
||||
typedefaultint_noconst
|
||||
};
|
||||
|
||||
enum {
|
||||
global_typeint_noconst = 10,
|
||||
global_typeboolfalse_noconst = false,
|
||||
global_typebooltrue_noconst = true,
|
||||
global_typebooltwo_noconst,
|
||||
global_typechar_noconst = 'C',
|
||||
global_typedefaultint_noconst
|
||||
};
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
|
@ -416,6 +416,28 @@ public class enum_thorough_proper_runme {
|
|||
if (enum_thorough_proper.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
|
||||
if (enum_thorough_proper.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typeint).swigValue() != 10) throw new RuntimeException("differentTypes 1 failed");
|
||||
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typeboolfalse).swigValue() != 0) throw new RuntimeException("differentTypes 2 failed");
|
||||
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typebooltrue).swigValue() != 1) throw new RuntimeException("differentTypes 3 failed");
|
||||
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typebooltwo).swigValue() != 2) throw new RuntimeException("differentTypes 4 failed");
|
||||
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typechar).swigValue() != 'C') throw new RuntimeException("differentTypes 5 failed");
|
||||
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typedefaultint).swigValue() != 'D') throw new RuntimeException("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough_proper.global_typeint;
|
||||
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough_proper.global_typeboolfalse;
|
||||
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough_proper.global_typebooltrue;
|
||||
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough_proper.global_typebooltwo;
|
||||
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough_proper.global_typechar;
|
||||
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough_proper.global_typedefaultint;
|
||||
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -416,6 +416,28 @@ public class enum_thorough_runme {
|
|||
if (enum_thorough.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
|
||||
if (enum_thorough.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if (enum_thorough.differentTypesTest(DifferentTypes.typeint).swigValue() != 10) throw new RuntimeException("differentTypes 1 failed");
|
||||
if (enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse).swigValue() != 0) throw new RuntimeException("differentTypes 2 failed");
|
||||
if (enum_thorough.differentTypesTest(DifferentTypes.typebooltrue).swigValue() != 1) throw new RuntimeException("differentTypes 3 failed");
|
||||
if (enum_thorough.differentTypesTest(DifferentTypes.typebooltwo).swigValue() != 2) throw new RuntimeException("differentTypes 4 failed");
|
||||
if (enum_thorough.differentTypesTest(DifferentTypes.typechar).swigValue() != 'C') throw new RuntimeException("differentTypes 5 failed");
|
||||
if (enum_thorough.differentTypesTest(DifferentTypes.typedefaultint).swigValue() != 'D') throw new RuntimeException("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough.global_typeint;
|
||||
if (enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough.global_typeboolfalse;
|
||||
if (enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough.global_typebooltrue;
|
||||
if (enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough.global_typebooltwo;
|
||||
if (enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough.global_typechar;
|
||||
if (enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough.global_typedefaultint;
|
||||
if (enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -416,6 +416,28 @@ public class enum_thorough_simple_runme {
|
|||
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
|
||||
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.end) != 3) throw new RuntimeException("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typeint) != 10) throw new RuntimeException("differentTypes 1 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough_simple.global_typeint;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough_simple.global_typeboolfalse;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough_simple.global_typebooltrue;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough_simple.global_typebooltwo;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough_simple.global_typechar;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough_simple.global_typedefaultint;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -416,6 +416,28 @@ public class enum_thorough_typeunsafe_runme {
|
|||
if (enum_thorough_typeunsafe.repeatTest(repeat.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
|
||||
if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeint) != 10) throw new RuntimeException("differentTypes 1 failed");
|
||||
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed");
|
||||
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed");
|
||||
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed");
|
||||
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed");
|
||||
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough_typeunsafe.global_typeint;
|
||||
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough_typeunsafe.global_typeboolfalse;
|
||||
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough_typeunsafe.global_typebooltrue;
|
||||
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough_typeunsafe.global_typebooltwo;
|
||||
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough_typeunsafe.global_typechar;
|
||||
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough_typeunsafe.global_typedefaultint;
|
||||
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5619,7 +5619,6 @@ etype : expr {
|
|||
($$.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;
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
@ -1274,11 +1274,15 @@ 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);
|
||||
// Deal with enum values that are not int
|
||||
int swigtype = SwigType_type(Getattr(n, "type"));
|
||||
if (swigtype == T_BOOL) {
|
||||
const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
|
||||
Setattr(n, "enumvalue", val);
|
||||
} else if (swigtype == T_CHAR) {
|
||||
String *val = NewStringf("'%s'", Getattr(n, "enumvalue"));
|
||||
Setattr(n, "enumvalue", val);
|
||||
Delete(val);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1329,11 +1333,12 @@ public:
|
|||
}
|
||||
} else {
|
||||
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
|
||||
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */
|
||||
SwigType *typemap_lookup_type = parent_name ? parent_name : type;
|
||||
SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum ");
|
||||
Setattr(n, "type", typemap_lookup_type);
|
||||
const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF);
|
||||
|
||||
String *return_type = Copy(tm);
|
||||
substituteClassname(typemap_lookup_type, return_type);
|
||||
const String *methodmods = Getattr(n, "feature:cs:methodmodifiers");
|
||||
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
|
||||
|
||||
|
@ -1362,6 +1367,7 @@ public:
|
|||
Printf(enum_code, " %s %s %s %s = %s;\n", methodmods, const_readonly, return_type, symname, value);
|
||||
Delete(value);
|
||||
}
|
||||
Delete(return_type);
|
||||
}
|
||||
|
||||
// Add the enum value to the comma separated list being constructed in the enum declaration.
|
||||
|
@ -1396,6 +1402,7 @@ public:
|
|||
String *tm;
|
||||
String *return_type = NewString("");
|
||||
String *constants_code = NewString("");
|
||||
Swig_save("constantWrapper", n, "value", NIL);
|
||||
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
|
||||
|
@ -1444,7 +1451,6 @@ public:
|
|||
|
||||
// Add the stripped quotes back in
|
||||
String *new_value = NewString("");
|
||||
Swig_save("constantWrapper", n, "value", NIL);
|
||||
if (SwigType_type(t) == T_STRING) {
|
||||
Printf(new_value, "\"%s\"", Copy(Getattr(n, "value")));
|
||||
Setattr(n, "value", new_value);
|
||||
|
|
|
@ -1349,11 +1349,15 @@ 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);
|
||||
// Deal with enum values that are not int
|
||||
int swigtype = SwigType_type(Getattr(n, "type"));
|
||||
if (swigtype == T_BOOL) {
|
||||
const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
|
||||
Setattr(n, "enumvalue", val);
|
||||
} else if (swigtype == T_CHAR) {
|
||||
String *val = NewStringf("'%s'", Getattr(n, "enumvalue"));
|
||||
Setattr(n, "enumvalue", val);
|
||||
Delete(val);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1394,11 +1398,12 @@ public:
|
|||
}
|
||||
} else {
|
||||
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
|
||||
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */
|
||||
SwigType *typemap_lookup_type = parent_name ? parent_name : type;
|
||||
SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum ");
|
||||
Setattr(n, "type", typemap_lookup_type);
|
||||
const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
|
||||
|
||||
String *return_type = Copy(tm);
|
||||
substituteClassname(typemap_lookup_type, return_type);
|
||||
const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
|
||||
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
|
||||
|
||||
|
@ -1419,6 +1424,7 @@ public:
|
|||
Printf(enum_code, " %s final static %s %s = %s;\n", methodmods, return_type, symname, value);
|
||||
Delete(value);
|
||||
}
|
||||
Delete(return_type);
|
||||
}
|
||||
|
||||
// Add the enum value to the comma separated list being constructed in the enum declaration.
|
||||
|
@ -1453,6 +1459,7 @@ public:
|
|||
String *tm;
|
||||
String *return_type = NewString("");
|
||||
String *constants_code = NewString("");
|
||||
Swig_save("constantWrapper", n, "value", NIL);
|
||||
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
|
||||
|
@ -1498,7 +1505,6 @@ public:
|
|||
|
||||
// Add the stripped quotes back in
|
||||
String *new_value = NewString("");
|
||||
Swig_save("constantWrapper", n, "value", NIL);
|
||||
if (SwigType_type(t) == T_STRING) {
|
||||
Printf(new_value, "\"%s\"", Copy(Getattr(n, "value")));
|
||||
Setattr(n, "value", new_value);
|
||||
|
|
Loading…
Reference in New Issue