diff options
author | Swati Sharma <itawswati@gmail.com> | 2012-07-30 17:36:06 +0000 |
---|---|---|
committer | Swati Sharma <itawswati@gmail.com> | 2012-07-30 17:36:06 +0000 |
commit | 7ec0a69a88c3636bf226a8fade561eb2ca66547d (patch) | |
tree | a3978777d202ca7b4431904619c2b77b442e089c | |
parent | ddc0b8c819be97724391a3f259fe2eb932a0abf2 (diff) | |
download | swig-7ec0a69a88c3636bf226a8fade561eb2ca66547d.tar.gz |
Fix for enums.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-objc@13433 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r-- | Source/Modules/objc.cxx | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Source/Modules/objc.cxx b/Source/Modules/objc.cxx index 24e3886d6..2249d9b32 100644 --- a/Source/Modules/objc.cxx +++ b/Source/Modules/objc.cxx @@ -690,21 +690,31 @@ int OBJECTIVEC::enumvalueDeclaration(Node *n) { Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL); String *symname = Getattr(n, "sym:name"); - String *value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex")); + String *value = Getattr(n,"enumvalue"); Node *parent = parentNode(n); - + Node *pparent=parentNode(parent); + String *enumname; + if (pparent && !Strcmp(nodeType(pparent), "class")) { // This is a nested enum, prefix the class name + String *classname = Getattr(pparent, "sym:name"); + enumname = NewStringf("%s_%s", classname, symname); + } + else { + enumname = Copy(symname); + } if (proxy_flag) { // Emit the enum item if (!GetFlag(n, "firstenumitem")) Printf(proxy_h_code, ",\n"); - Printf(proxy_h_code, " %s", symname); - if (value) - Printf(proxy_h_code, " = %s", value); + Printf(proxy_h_code, " %s", enumname); + if (value){ + value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex")); + Printf(proxy_h_code, " = %s", value); + } } - // Keep track that the currently processed enum has at least one value SetFlag(parent, "nonempty"); Swig_restore(n); + Delete(enumname); return SWIG_OK; } |