diff options
| author | Artem Serebriyskiy <v.for.vandal@gmail.com> | 2013-11-13 15:16:09 +0400 |
|---|---|---|
| committer | Artem Serebriyskiy <v.for.vandal@gmail.com> | 2014-02-19 13:34:49 +0400 |
| commit | 6d49a57b535a0a9cc479b2cd8367371c64808d39 (patch) | |
| tree | 85739d56486217d6c5b9a5a113f08a74eb29ed6f /Source/Modules/lua.cxx | |
| parent | 4b0ed733172c410103cb7bcc74b13243e10b06aa (diff) | |
| download | swig-6d49a57b535a0a9cc479b2cd8367371c64808d39.tar.gz | |
Add support for C-style enums in C mode. And tests.
In backward compatible mode C style enums binding are correctly
generated
Diffstat (limited to 'Source/Modules/lua.cxx')
| -rw-r--r-- | Source/Modules/lua.cxx | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 75c94cc6b..116e6a26a 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -139,6 +139,7 @@ private: STATIC_FUNC, STATIC_VAR, STATIC_CONST, // enums and things like static const int x = 5; + ENUM_CONST, // This is only needed for backward compatibility in C mode STATES_COUNT }; @@ -1010,8 +1011,16 @@ public: bool make_v2_compatible = v2_compatibility && getCurrentClass() != 0; if (make_v2_compatible) { - target_name_v2 = Swig_name_member(0, class_symname, target_name); - iname_v2 = Swig_name_member(0, class_symname, iname); + // Special handling for enums in C mode - they are not prefixed with structure name + if(!CPlusPlus && current[ENUM_CONST]) { + target_name_v2 = target_name; + DohIncref(target_name_v2); + iname_v2 = iname; + DohIncref(iname_v2); + } else { + target_name_v2 = Swig_name_member(0, class_symname, target_name); + iname_v2 = Swig_name_member(0, class_symname, iname); + } n_v2 = Copy(n); //Printf( stdout, "target name v2: %s, symname v2 %s\n", target_name_v2.ptr(), iname_v2.ptr());// TODO:REMOVE if (!luaAddSymbol(iname_v2, n, class_parent_nspace)) { @@ -1074,8 +1083,10 @@ public: virtual int enumDeclaration(Node *n) { current[STATIC_CONST] = true; + current[ENUM_CONST] = true; int result = Language::enumDeclaration(n); current[STATIC_CONST] = false; + current[ENUM_CONST] = false; return result; } |
