Add c++11 strongly typed enum support for Go

This commit is contained in:
William S Fulton 2014-11-28 20:40:37 +00:00
commit 713d3d5973
2 changed files with 187 additions and 3 deletions

View file

@ -1959,15 +1959,28 @@ private:
* ------------------------------------------------------------------------ */
virtual int enumvalueDeclaration(Node *n) {
Swig_require("enumvalueDeclaration", n, "*sym:name", NIL);
Node *parent = parentNode(n);
if (!is_public(n)) {
return SWIG_OK;
}
if (Getattr(parentNode(n), "unnamed")) {
if (Getattr(parent, "unnamed")) {
Setattr(n, "type", NewString("int"));
} else {
Setattr(n, "type", Getattr(parentNode(n), "enumtype"));
Setattr(n, "type", Getattr(parent, "enumtype"));
}
return goComplexConstant(n, Getattr(n, "type"));
if (GetFlag(parent, "scopedenum")) {
String *symname = Getattr(n, "sym:name");
symname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
Setattr(n, "sym:name", symname);
Delete(symname);
}
int ret = goComplexConstant(n, Getattr(n, "type"));
Swig_restore(n);
return ret;
}
/* -----------------------------------------------------------------------