Nested class improvements - Fixed inconsistency in handling C++ nested classes - sometimes they were treated as forward declarations, other times as if C nested struct was parsed. Added the nestedworkaround feature for C++ nested class handling. Document improved nested class handling. Numerous C and C++ nested struct/class/union test cases added.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11734 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-11-11 00:30:34 +00:00
commit ebed6508e4
12 changed files with 300 additions and 82 deletions

View file

@ -0,0 +1,38 @@
%module nested_workaround
// Similar to "Nested classes" documentation example.
class Inner {
int val;
public:
Inner(int v = 0) : val(v) {}
void setValue(int v) { val = v; }
int getValue() const { return val; }
};
%nestedworkaround Outer::Inner;
%inline %{
class Outer {
public:
class Inner {
int val;
public:
Inner(int v = 0) : val(v) {}
void setValue(int v) { val = v; }
int getValue() const { return val; }
};
Inner createInner(int v) const { return Inner(v); }
int getInnerValue(const Inner& i) const { return i.getValue(); }
Inner doubleInnerValue(Inner inner) {
inner.setValue(inner.getValue() * 2);
return inner;
}
};
%}
// We've fooled SWIG into thinking that Inner is a global class, so now we need
// to trick the C++ compiler into understanding this apparent global type.
%{
typedef Outer::Inner Inner;
%}