swig/Examples/test-suite/template_nested.i
Vladimir Kalinin b63c4839fe Nested classes support
Closes #89
Squash merge branch 'master' of https://github.com/wkalinin/swig into wkalinin-nested

By Vladimir Kalinin
* 'master' of https://github.com/wkalinin/swig:
  CPlusPlusOut mode for Octave
  nested class illustration
  fixed "Abstract" flag for nested classes added an example enabled anonymous nested structs runtime test
  porting
  warnings disabled
  porting fixes
  java runtime tests ported
  nested class closing bracket offset fixed
  removed double nested template (not supported by %template parsing)
  template_nested test extended
  parent field made public
  property access fixed
  replaced tabs with spaces
  warning W-reorder
  deprecated warnings removed, derived_nested runtime test added
  optimized string indenting
  Nested classes indenting
  nested classes docs
  fixed the order in which flattened inner classes are added after the outer
  Private nested classes were getting into the type table.
  Java getProxyName() fix for nested classes fixes the case when nested classes is forward declared
  Fix for a case when a nested class inherits from the same base as the outer. (Base class constructor declaration is found first in this case)
  merge fix
  nested C struct first immediate declaration incorrectly renamed sample fixed
  tests updated to reflect nested classes support
  Java nested classes support (1)
  flattening should remove the link to the outer class
  access mode correctly set/restored for nested classes
  nested templates should be skipped while flattening (template nodes themselves, not expanded versions) also non-public nested classes should be ignored
  If nested classes are not supported, default behaviour is flattening, not ignoring flag "nested" is preserved, so, the nested classes can be ignored by user
  nested workaround test updated
  template instantiated within a class is marked as nested for ignoring purposes
  %ignore not applied to the nested classed, because "nested" flag is set too late
  typedef name takes precedence over the real name (reason?)
  unnamed structs should be processed for all the languages
  nested C struct instances are wrapped as "immutable"
  tree building
  typedef declaration for unnamed C structures fixed
  nested classes "flattening"
  fixed %ignoring nested classes
  renamed "nested" attribute to "nested:outer" added "nested" flag, to be used with $ignore (it is not removed while flattening) added nestedClassesSupported() function to the Language interface
  renamed "nested" attribute to "nested:outer" added "nested" flag, to be used with $ignore (it is not removed while flattening) added nestedClassesSupported() function to the Language interface
  tree iteration fix
  dirclassname variable names unified memory issue fixed
  merge error
  ignore unnamed structs for C++
  unnamed nested C structs naming & unnesting
  class added to classes hash under typedef name
  private nested classes skipped
  test updated due to nested templates support
  anonymous structs with inheritance fixed nested_class test to allow anonymous structs w/o declarator
  tests updated: nested workaround removed from namespace_class.i propagated nested template declaration to the C++ file
  injected members scope
  nested tempplates fixes, nested structures in "C" mode parsing added utility function "appendSibling" (like "appendChild")
  nested unnamed structures parsing fixes, access mode restored on nested class end, tdname is properly patched with outer class name prefix
  memory management fixes
  nested templates (1)
  Nested unnamed structs
  Nested class support (1)
  Nested class support (1)
2013-11-29 07:02:34 +00:00

117 lines
3.5 KiB
OpenEdge ABL

%module template_nested
// Test nested templates - that is template classes and template methods within a class.
namespace ns {
template <class T> struct ForwardTemplate;
}
%{
namespace ns {
template <class T> struct ForwardTemplate {
void tmethod(T t) {}
};
}
%}
%inline %{
namespace ns {
class NormalClass {
public:
NormalClass() {}
~NormalClass() {}
};
template <class T> struct NormalTemplate {
void tmethod(T t) {}
};
}
%}
%template(T_NormalTemplateNormalClass) ns::NormalTemplate<ns::NormalClass>;
%template(T_NormalTemplateInt) ns::NormalTemplate<int>;
%inline %{
namespace ns {
class OuterClass {
public:
template <class T> struct Inner1 {
template <class U> struct SuperInner1 {
void method1(U t) {}
};
template <class V> struct SuperInner2 {
void method1(V t) {}
};
template <class W> void tmethod(W w) {}
template <class X> void tmethodAgain(X x) {}
template <class Y> struct SuperBase : public SuperInner1<Y> {
void method1(Y y) {}
};
};
Inner1<int> useInner1(const Inner1<int>& inner) { return inner; }
template <class Z> void InnerTMethod(Z z) {}
template <class T> class Inner2 : public NormalTemplate<T> {
public:
template <class U> class SuperInner1 {
public:
SuperInner1() {}
void method1(U t) {}
};
template <class V> struct SuperInner2 {
void method1(V t) {}
};
int embeddedVar;
template <class X> void tmethod(X x) {}
template <class Y> struct SuperBase : public SuperInner1<Y> {
void method1(Y y) {}
};
};
Inner2<int> useInner2(const Inner2<int>& inner) { return inner; }
Inner2<NormalClass> useInner2Again(const Inner2<NormalClass>& inner) { return inner; }
int iii;
};
struct ABC {
ABC() {}
~ABC() {}
};
struct TemplateFuncs {
template <class X> X templateMethod1(X x) { return x; }
template <class X> X templateMethod2(X x) { return x; }
};
template <typename UU> struct OuterTemplate {
template <typename VV> struct NestedInnerTemplate1 {
template <typename Z> void NestedInnerInnerTMethod(Z z) {}
void hohum() {}
};
template <typename W> void NestedInnerTMethod(UU u, W w) {}
template <typename VV> struct NestedInnerTemplate2 {
void hohum() {}
};
UU hohum(UU u) { return u; }
template <typename VV> struct NestedInnerTemplate3 : public NestedInnerTemplate2<VV> {
void hohum() {}
};
struct NestedStruct {
NestedStruct() {}
void hohum() {}
};
NestedInnerTemplate1<short> useNestedInnerTemplate1(const NestedInnerTemplate1<short>& inner) { return inner; }
NestedInnerTemplate2<short> useNestedInnerTemplate2(const NestedInnerTemplate2<short>& inner) { return inner; }
NestedInnerTemplate3<short> useNestedInnerTemplate3(const NestedInnerTemplate3<short>& inner) { return inner; }
NestedStruct useNestedStruct(const NestedStruct& inner) { return inner; }
};
}
%}
%template(T_OuterTMethodNormalClass) ns::OuterClass::InnerTMethod<ns::NormalClass>;
%template(T_TemplateFuncs1Int) ns::TemplateFuncs::templateMethod1<int>;
%template(T_TemplateFuncs2Double) ns::TemplateFuncs::templateMethod2<double>;
%template(T_NestedOuterTemplateDouble) ns::OuterTemplate<double>;
%template(T_OuterClassInner1Int) ns::OuterClass::Inner1<int>;
%template(T_OuterClassInner2NormalClass) ns::OuterClass::Inner2<ns::NormalClass>;
%template(T_OuterClassInner2Int) ns::OuterClass::Inner2<int>;