Fix Octave C enums wrapping when the generated code is C++ compiled

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12022 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-05-11 22:53:33 +00:00
commit 3cf41050b5
3 changed files with 21 additions and 8 deletions

View file

@ -760,6 +760,7 @@ public:
SwigType *type = Getattr(n, "type");
String *rawval = Getattr(n, "rawval");
String *value = rawval ? rawval : Getattr(n, "value");
String *cppvalue = Getattr(n, "cppvalue");
String *tm;
if (!addSymbol(iname, n))
@ -775,7 +776,7 @@ public:
if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
Replaceall(tm, "$source", value);
Replaceall(tm, "$target", name);
Replaceall(tm, "$value", value);
Replaceall(tm, "$value", cppvalue ? cppvalue : value);
Replaceall(tm, "$nsname", iname);
Printf(f_init, "%s\n", tm);
} else {

View file

@ -807,11 +807,15 @@ class TypePass:private Dispatcher {
value = name;
if (Strcmp(value, name) == 0) {
String *new_value;
if (((nsname) || (inclass)) && cparse_cplusplus) {
if ((nsname || inclass) && cparse_cplusplus) {
new_value = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
} else {
new_value = NewString(value);
}
if ((nsname || inclass) && !cparse_cplusplus) {
String *cppvalue = NewStringf("%s::%s", SwigType_namestr(Swig_symbol_qualified(n)), value);
Setattr(n, "cppvalue", cppvalue); /* for target languages that always generate C++ code even when wrapping C code */
}
Setattr(n, "value", new_value);
Delete(new_value);
}